当前位置: 首页>>代码示例>>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;未经允许,请勿转载。