當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript fs-extra.writeJsonSync函數代碼示例

本文整理匯總了TypeScript中fs-extra.writeJsonSync函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript writeJsonSync函數的具體用法?TypeScript writeJsonSync怎麽用?TypeScript writeJsonSync使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了writeJsonSync函數的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: it

    it("prefers 'package.json' over 'lerna.json'", function() {
      fs.writeJsonSync(path.join(tmpDir, "lerna.json"), {
        version: "1.0.0-lerna.0",
        changelog: { repo: "foo/lerna", nextVersionFromMetadata: true },
      });

      fs.writeJsonSync(path.join(tmpDir, "package.json"), {
        version: "1.0.0-package.0",
        changelog: { repo: "foo/package", nextVersionFromMetadata: true },
      });

      const result = fromPath(tmpDir);
      expect(result.nextVersion).toEqual("v1.0.0-package.0");
      expect(result.repo).toEqual("foo/package");
    });
開發者ID:lerna,項目名稱:lerna-changelog,代碼行數:15,代碼來源:configuration.spec.ts

示例2: before

 before(() => {
     file = path.resolve(__dirname, "./tmp.log");
     fse.removeSync(file);
     fse.writeJsonSync(file, TEST_JSON);
     file0dir = path.resolve(__dirname, "./tmp/file/");
     fse.removeSync(file0dir);
 });
開發者ID:node-dmr,項目名稱:dmr-source,代碼行數:7,代碼來源:source-file.ts

示例3: persistToFile

 persistToFile() {
   this.debug('Saving configuration to persistent storage: %o', global._ConfigurationPersistence);
   try {
     return fs.writeJsonSync(this.configFile, global._ConfigurationPersistence, {spaces: 2});
   } catch (error) {
     this.debug('An error occurred while persisting the configuration: %s', error);
   }
 }
開發者ID:wireapp,項目名稱:wire-desktop,代碼行數:8,代碼來源:ConfigurationPersistence.ts

示例4: verifyMetaFile

export function verifyMetaFile() {
  let dir = dirHelper(".meta");
  try {
    fs.ensureFileSync(dir);
    let contents = fs.readJsonSync(dir, {throws: false});
    if(!contents) {
      fs.writeJsonSync(dir, { settings: {} });
      console.log("Initialized meta file")
    } else {
      console.log("Meta file already exists!");
    }
  } catch (err) {
    console.error("Meta file error:", err);
  }
}
開發者ID:zakarhino,項目名稱:noam,代碼行數:15,代碼來源:saveNote.ts

示例5: verifyDatabaseFile

export function verifyDatabaseFile() {
  let dir = dirHelper("notes.noam");
  try {
    fs.ensureFileSync(dir);
    let contents = fs.readJsonSync(dir, {throws: false});
    if(!contents) {
      fs.writeJsonSync(dir, { notes: {} });
      console.log("Initialied note database!");
    } else {
      console.log("Note database already exists!");
    }
  } catch (err) {
    console.error("Note database error:", err);
  }
}
開發者ID:zakarhino,項目名稱:noam,代碼行數:15,代碼來源:saveNote.ts

示例6: processFile

async function processFile ({ filePath, tempPath, entryBaseName }) {
  const indexJsStr = `
  import {AppRegistry} from 'react-native';
  import App from '../${entryBaseName}';
  // import {name as appName} from '../app.json';

  AppRegistry.registerComponent('${moduleName}', () => App);`

  if (!fs.existsSync(filePath)) {
    return
  }
  const dirname = path.dirname(filePath)
  const destDirname = dirname.replace(tempPath, jdreactPath)
  const destFilePath = path.format({dir: destDirname, base: path.basename(filePath)})
  const indexFilePath = path.join(tempPath, 'index.js')
  const tempPkgPath = path.join(tempPath, 'package.json')

  // generate jsbundles/moduleName.js
  if (filePath === indexFilePath) {
    const indexDistDirPath = path.join(jdreactPath, 'jsbundles')
    const indexDistFilePath = path.join(indexDistDirPath, `${moduleName}.js`)
    fs.ensureDirSync(indexDistDirPath)
    fs.writeFileSync(indexDistFilePath, indexJsStr)
    Util.printLog(processTypeEnum.GENERATE, `${moduleName}.js`, indexDistFilePath)
    return
  }

  // genetate package.json
  if (filePath === tempPkgPath) {
    const destPkgPath = path.join(jdreactPath, 'package.json')
    const templatePkgPath = path.join(jdreactTmpDirname, 'pkg')
    const tempPkgObject = fs.readJsonSync(tempPkgPath)
    const templatePkgObject = fs.readJsonSync(templatePkgPath)
    templatePkgObject.name = `jdreact-jsbundle-${moduleName}`
    templatePkgObject.dependencies = Object.assign({}, tempPkgObject.dependencies, templatePkgObject.dependencies)
    fs.writeJsonSync(destPkgPath, templatePkgObject, {spaces: 2})
    Util.printLog(processTypeEnum.GENERATE, 'package.json', destPkgPath)
    return
  }

  fs.ensureDirSync(destDirname)
  fs.copySync(filePath, destFilePath)
  Util.printLog(processTypeEnum.COPY, _.camelCase(path.extname(filePath)).toUpperCase(), filePath)
}
開發者ID:YangShaoQun,項目名稱:taro,代碼行數:44,代碼來源:convert_to_jdreact.ts

示例7: updateDistPackageJson

function updateDistPackageJson(directory: string, newDirectory: string): void {
	const srcPkgJsonPath = resolve(directory, "package.json");
	const distPkgJsonPath = resolve(newDirectory, "package.json");

	const srcPkgJson = readJsonSync(srcPkgJsonPath) as PackageJson;

	// update the dist package json
	const { version, dependencies, peerDependencies, devDependencies } = srcPkgJson;

	const distPkgJson: PackageJson = {
		...readJsonSync(distPkgJsonPath),
		version,
		dependencies,
		devDependencies,
		peerDependencies
	}

	writeJsonSync(distPkgJsonPath, distPkgJson, { spaces: 2 });
}
開發者ID:fossabot,項目名稱:angular-skyhook,代碼行數:19,代碼來源:release.ts

示例8:

	// stub
});
fs.writeJSON(file, object).then(() => {
	// stub
});
fs.writeJson(file, object, errorCallback);
fs.writeJson(file, object, writeOptions, errorCallback);
fs.writeJSON(file, object, errorCallback);
fs.writeJSON(file, object, writeOptions, errorCallback);
fs.writeJson(file, object, writeOptions).then(() => {
	// stub
});
fs.writeJSON(file, object, writeOptions).then(() => {
	// stub
});
fs.writeJsonSync(file, object, writeOptions);
fs.writeJSONSync(file, object, writeOptions);

fs.ensureDir(path).then(() => {
	// stub
});
fs.ensureDir(path, errorCallback);
fs.ensureDirSync(path);

fs.ensureFile(path).then(() => {
	// stub
});
fs.ensureFile(path, errorCallback);
fs.ensureFileSync(path);
fs.ensureLink(path).then(() => {
	// stub
開發者ID:gilamran,項目名稱:DefinitelyTyped,代碼行數:31,代碼來源:fs-extra-tests.ts

示例9: getTasks

    getTasks(environmentTasksDirectory).map((taskDirectory) => {
        const taskFilePath = path.join(taskDirectory.directory, "task.json");
        const task = fs.readJsonSync(taskFilePath) as AzureDevOpsTasksSchema;

        task.id = env.TaskIds[taskDirectory.name];
        if (task.id) {
            task.friendlyName += env.DisplayNamesSuffix;

            task.version = {
                Major: version.major,
                Minor: version.minor,
                Patch: version.patch,
            };

            if (task.helpMarkDown) {
                task.helpMarkDown = task.helpMarkDown.replace("#{Version}#", version.getVersionString());
            }

            if (task.inputs) {
                task.inputs.forEach((input) => {
                    const mappedType = endpointMap[input.type];
                    if (mappedType) {
                        input.type = mappedType;
                    }
                });
            }

            fs.writeJsonSync(taskFilePath, task);

            const taskLocFilePath = path.join(taskDirectory.directory, "task.loc.json");
            if (fs.existsSync(taskLocFilePath)) {
                const taskLoc = fs.readJsonSync(taskLocFilePath);
                taskLoc.id = env.TaskIds[taskDirectory.name];
                taskLoc.friendlyName += env.DisplayNamesSuffix;

                taskLoc.version.Major = version.major;
                taskLoc.version.Minor = version.minor;
                taskLoc.version.Patch = version.patch;
                if (taskLoc.helpMarkDown) {
                    taskLoc.helpMarkDown = taskLoc.helpMarkDown.replace("#{Version}#", version.getVersionString());
                }

                fs.writeJsonSync(taskLocFilePath, taskLoc);
                const locfilesDirectory = path.join(taskDirectory.directory, "Strings/resources.resjson");
                if (fs.existsSync(locfilesDirectory)) {
                    const langs = fs.readdirSync(locfilesDirectory);
                    for (const element of langs) {
                        const resourceFile = path.join(locfilesDirectory, element, "resources.resjson");
                        if (fs.existsSync(resourceFile)) {
                            const resource = fs.readJsonSync(resourceFile);
                            resource["loc.helpMarkDown"] = resource["loc.helpMarkDown"]
                                .replace("#{Version}#", version.getVersionString());
                            fs.writeJsonSync(resourceFile, resource);
                        }
                    }
                }
            }

            const taskId = taskDirectory.name.replace(/([A-Z])/g, "-$1").toLowerCase().replace(/^[-]+/, "");
            extension.contributions.push({
                description: task.description,
                id: taskId + "-task",
                properties: {
                    name: "Tasks/" + taskDirectory.name,
                },
                targets: [
                    "ms.vss-distributed-task.tasks",
                ],
                type: "ms.vss-distributed-task.task",
            });
        } else {
            fs.removeSync(taskDirectory.directory);
        }
    });
開發者ID:geeklearningio,項目名稱:gl-vsts-tasks-build-scripts,代碼行數:74,代碼來源:package.ts


注:本文中的fs-extra.writeJsonSync函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。