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


TypeScript jsonfile.writeFileSync函數代碼示例

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


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

示例1: function

gulp.task('!manifest', function () {
  const meta = util.currentPackage();
  const copyInst = util.getCopyInstruction(meta);

  const pkgDest = Path.join(copyInst.to, 'package.json');
  const pkgJson = jsonfile.readFileSync(util.root('package.json'));

  const localPackageJsonPath = util.root(util.FS_REF.SRC_CONTAINER, meta.dir, 'package.json');
  if (fs.existsSync(localPackageJsonPath)) {
    Object.assign(
      pkgJson,
      jsonfile.readFileSync(localPackageJsonPath)
    )
  }

  PKGJSON_KEYS_TO_DELETE.forEach( k => { delete pkgJson[k] });

  pkgJson.name = meta.dir;
  pkgJson.main = `${util.FS_REF.BUNDLE_DIR}/${meta.umd}.rollup.umd.js`;
  pkgJson.module = `${util.FS_REF.BUNDLE_DIR}/${meta.umd}.es5.js`;
  pkgJson.es2015 = `${util.FS_REF.BUNDLE_DIR}/${meta.umd}.js`;
  pkgJson.typings = `${util.FS_REF.SRC_CONTAINER}/${util.getMainOutputFileName(meta)}.d.ts`;

  util.tryRunHook(meta.dir, 'packageJSON', pkgJson);

  jsonfile.writeFileSync(pkgDest, pkgJson, {spaces: 2});
});
開發者ID:shlomiassaf,項目名稱:ng2-chess,代碼行數:27,代碼來源:manifest.ts

示例2: require

        let prepareFunction = () => {
            if (pluginBinding.options.shrinkWrap) {
                pluginBinding.shellExecuteNpm(packagePath, [ "shrinkwrap" ]);

                //
                // Filter out any 'resolved' fields

                let shrinkWrapFilePath = path.join(packagePath, "npm-shrinkwrap.json");
                let shrinkwrap = require(shrinkWrapFilePath);

                function replacer(key, val) {
                    if (key === "resolved" && this.from && this.version) {
                        return undefined;
                    }

                    return val;
                }

                fs.writeFileSync(shrinkWrapFilePath, JSON.stringify(shrinkwrap, replacer, 2));
            }

            let versionBump = pluginBinding.options.versionBump;

            if (versionBump) {
                packageDescriptor = bumpVersion(packageDescriptor, packagePath, versionBump);

                jsonFile.writeFileSync(path.join(packagePath, "package.json"), packageDescriptor, { spaces: 4 });

                file.contents = new Buffer(JSON.stringify(packageDescriptor));
            }
        };
開發者ID:i-e-b,項目名稱:gulp-npmworkspace,代碼行數:31,代碼來源:PublishPackages.ts

示例3: file

  @util.GulpClass.Task({
    name: 'misc:syncConfig',
    desc: `Sync the main tsconfig file (tsconfig.json) and JEST configuration file with paths information.
This is required after each change to a package configuration that results in a file structure change.  
This includes adding, removing or changing a package name. Changing the top-level scope, etc..`
  })
  syncConfig() {
    const tsConfig = jsonfile.readFileSync(util.root('tsconfig.json'));
    tsConfig.compilerOptions.paths = util.tsConfigPaths();
    util.tryRunHook('./', 'tsconfig', tsConfig);
    jsonfile.writeFileSync(util.root('tsconfig.json'), tsConfig, {spaces: 2});

    const jestConfig = jsonfile.readFileSync(util.root('jest.library.config.json'));
    jestConfig.moduleNameMapper = util.jestAlias();
    util.tryRunHook('./', 'jestConfig', jestConfig);
    jsonfile.writeFileSync(util.root('jest.library.config.json'), jestConfig, {spaces: 2});
  }
開發者ID:shlomiassaf,項目名稱:ng2-chess,代碼行數:17,代碼來源:misc.ts

示例4: Promise

      .then( () => {
        const p = util.root(util.currentPackage().tsConfigObj.compilerOptions.outDir);
        del.sync(p);

        const tsConfig = jsonfile.readFileSync(util.root(util.FS_REF.TS_CONFIG_TMP));
        tsConfig.compilerOptions.target = 'es5';
        jsonfile.writeFileSync(util.root(util.FS_REF.TS_CONFIG_TMP), tsConfig, {spaces: 2});

        return new Promise( (resolve, reject) => webpack(config).run((err, stats) => err ? reject(err) : resolve(stats)) );
      })
開發者ID:shlomiassaf,項目名稱:ng2-chess,代碼行數:10,代碼來源:build.ts

示例5: update

export function jsonPatch<T>(readPath: string): { update: (handler: (data: T) => (T | null | void)) => { save: (savePath: string) => void } } {
  return {
    update(handler: (data: T) => T): any {
      const tsconfig = jsonfile.readFileSync(readPath);
      const data = handler(tsconfig);
      return {
        save(savePath: string): void {
          if (data !== null) {
            jsonfile.writeFileSync(savePath, data || tsconfig, {spaces: 2});
          }
        }
      };
    }
  };
}
開發者ID:shlomiassaf,項目名稱:ng2-chess,代碼行數:15,代碼來源:fs.ts

示例6: function

var saveJSON = function (obj:any, filename: string){
  var jsonfile = require('jsonfile');
  jsonfile.writeFileSync(filename, obj)
}
開發者ID:mixxr,項目名稱:18_aws_rest,代碼行數:4,代碼來源:loader.ts

示例7:

    err;
});

// $ExpectType void
jsonfile.writeFile(file, obj, { spaces: 2 }, err => {
    // $ExpectType ErrnoException
    err;
});

// $ExpectType void
jsonfile.writeFile(file, obj, { spaces: 2, EOL: '\r\n' }, err => {
    // $ExpectType ErrnoException
    err;
});

// $ExpectType void
jsonfile.writeFile(file, obj, { flag: 'a' }, err => {
    // $ExpectType ErrnoException
    err;
});

// $ExpectType Promise<void>
jsonfile.writeFile(file, obj);
// $ExpectType Promise<void>
jsonfile.writeFile(file, obj, { flag: 'a' });

jsonfile.writeFileSync(file, obj);
jsonfile.writeFileSync(file, obj, { spaces: 2 });
jsonfile.writeFileSync(file, obj, { spaces: 2, EOL: '\r\n' });
jsonfile.writeFileSync(file, obj, { flag: 'a' });
開發者ID:CNBoland,項目名稱:DefinitelyTyped,代碼行數:30,代碼來源:jsonfile-tests.ts

示例8: writeFileSync

 writeFileSync(filename: string, obj: any, options?: any): any {
   return jsonfile.writeFileSync(filename, obj, options);
 }
開發者ID:jreeme,項目名稱:firmament-yargs,代碼行數:3,代碼來源:safe-json-impl.ts


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