• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript jsonfile.readFileSync函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中jsonfile.readFileSync函数的典型用法代码示例。如果您正苦于以下问题:TypeScript readFileSync函数的具体用法?TypeScript readFileSync怎么用?TypeScript readFileSync使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了readFileSync函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: getSettings

export function getSettings():Isettings{
    //Give some default values
    let settings:Isettings = {
        port : getRandomPort()
    };
    
    // *******************************************
    // Checks that iisexpress.json exist
    // *******************************************
	let settingsFilePath = vscode.workspace.rootPath + "\\.vscode\\iisexpress.json";
    
    //use -> https://www.npmjs.com/package/jsonfile
    var jsonfile = require('jsonfile');
    
    try {
        //Check if we can find the file path (get stat info on it)
        let fileCheck = fs.statSync(settingsFilePath);
        
        //read file .vscode\iisexpress.json and overwrite port property from iisexpress.json
        settings = jsonfile.readFileSync(settingsFilePath);
    }
    catch (err) {
        //file didn't exist so
        //create .vscode\iisexpress.json and append settings object
       	jsonfile.writeFile(settingsFilePath, settings, {spaces: 2}, function (err) {
            console.error(err);
        });
    }
    
    //Return an object back from verifications
    return settings;
    
}
开发者ID:EbXpJ6bp,项目名称:IIS-Express-Code,代码行数:33,代码来源:settings.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: decrypt

function decrypt() {
  file = "data.json";

  var objRead = jsonfile.readFileSync(file); //JSON Object containing credentials

  encryptedUsername = objRead.username;
  encryptedPassword = objRead.password;
}
开发者ID:cchampernowne,项目名称:project-seed,代码行数:8,代码来源:readCredentials.ts


示例5: 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


示例6: join

 fs.readdirSync(current).forEach(function (file) {
   if (file === 'meta.json') {
     file = join('.', sep, current, file);
     let currentChapterAbr = file.match(/(ch\d+)/)[0];
     let chapter = CHAPTERS_MAP[currentChapterAbr];
     result.push({
       chapter,
       file: current,
       meta: jsonfile.readFileSync(file)
     });
   } else if (fs.lstatSync(join(current, file)).isDirectory()) {
     result = result.concat(readMetadata(join(current, file), appRoot));
   }
 });
开发者ID:HalasNet,项目名称:switching-to-angular2,代码行数:14,代码来源:template_locals.ts


示例7: 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


示例8: getConfigurationData

	public getConfigurationData(configurationFileName: string): any {
		var self = this;
		var terminal = this.terminal;
		var configurationData: any = null;

		// Read the main resource configuration file from disk.
		terminal.echoInfo("Reading configuration filename \"" + configurationFileName + "\"");

		try {
			configurationData = jsonFile.readFileSync(configurationFileName, { throws: true });
		}
		catch (exception) {
			terminal.echoScreamingError("Error parsing configuration file, " + exception.toString());
			process.exit(1);
		}	

		return configurationData;
	}	
开发者ID:duffman,项目名称:superbob,代码行数:18,代码来源:configuration.processor.ts


示例9: if

 dialog.showOpenDialog(dialogOptions, filename => {
   if (
     args.action === "CertPath" ||
     args.action === "KeyPath" ||
     args.action === "AssetPath"
   ) {
     event.sender.send("open", {
       action: args.action,
       path: filename
     });
   } else if (args.action === "OpenProject") {
     if (filename) {
       event.sender.send("open", {
         action: args.action,
         path: filename,
         content: jsonfile.readFileSync(filename[0])
       });
     }
   }
 });
开发者ID:Raathigesh,项目名称:Atmo,代码行数:20,代码来源:messageHandler.ts



注:本文中的jsonfile.readFileSync函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript jsonfile.writeFile函数代码示例发布时间:2022-05-25
下一篇:
TypeScript main.visit函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap