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

TypeScript fs-extra.readJson函数代码示例

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

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



在下文中一共展示了readJson函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: async

 async () => {
   const scanResultJson =
       await readJson(path.join(manifestsDir, 'simple_expected.json'));
   const expectedManifestResult =
       await readJson(path.join(manifestsDir, 'simple_source.json'));
   const actualResult = serializePackageScanResult(
       new Map(scanResultJson[0]),
       new Map(scanResultJson[1]),
       urlHandler);
   assert.deepEqual(actualResult, expectedManifestResult);
 });
开发者ID:,项目名称:,代码行数:11,代码来源:


示例2: downloadSeriesAsync

 await mio.usingAsync(mio.Browser.createAsync(), async browser => {
   let fileNames = await fs.readdir(shared.path.normal());
   for (let fileName of fileNames) {
     let fileExtension = path.extname(fileName);
     if (fileExtension === shared.extension.json) {
       let metaProviderPath = shared.path.normal(fileName);
       let metaProvider = await fs.readJson(metaProviderPath) as shared.IMetaProvider;
       for (let url in metaProvider) {
         let timer = new mio.Timer();
         let awaiter = mio.scrapeAsync(browser, url);
         if (awaiter) {
           console.log(`Awaiting ${url}`);
           await mio.usingAsync(awaiter, async series => {
             if (series.title !== metaProvider[url]) throw new Error(`Series at ${url} property changed: title`)
             if (series.url !== url) throw new Error(`Series at ${url} property changed: url`);
             console.log(`Fetching ${series.title}`);
             await mio.commands.updateSeriesAsync(series);
             await downloadSeriesAsync(series);
             console.log(`Finished ${series.title} (${timer})`);
           });
         } else {
           console.log(`Rejected ${url}`);
         }
       }
     }
   }
 });
开发者ID:Deathspike,项目名称:mangarack,代码行数:27,代码来源:download.ts


示例3: found

(async () => {
  const dirsToCheck = [];

  for (const subDir of await fs.readdir(PACKAGES_DIR)) {
    for (const packageDir of await fs.readdir(path.resolve(PACKAGES_DIR, subDir))) {
      dirsToCheck.push(path.resolve(PACKAGES_DIR, subDir, packageDir));
    }
  }

  let bad = false;
  for (const dir of dirsToCheck) {
    const pj = await fs.readJson(path.resolve(dir, 'package.json'));
    if (pj.name === '@electron-forge/cli') continue;
    if (!await fs.pathExists(path.resolve(dir, pj.main))) {
      console.error(`${`[${pj.name}]`.cyan}:`,  `Main entry not found (${pj.main})`.red);
      bad = true;
    }
    if (!pj.typings || !await fs.pathExists(path.resolve(dir, pj.typings))) {
      console.error(`${`[${pj.name}]`.cyan}:`, `Typings entry not found (${pj.typings})`.red);
      bad = true;
    }
  }

  if (bad) {
    process.exit(1);
  }
})().catch(console.error);
开发者ID:balloonzzq,项目名称:electron-forge,代码行数:27,代码来源:test-dist.ts


示例4: Promise

 return new Promise((resolve, reject) => {
   readJson(path, (err, r: any) => {
     if (err) {
       return reject(err);
     }
     return resolve(r)
   })
 });
开发者ID:tbtimes,项目名称:ledeTwo,代码行数:8,代码来源:utils.ts


示例5: createSeriesAsync

export async function createSeriesAsync(series: mio.IScraperSeries) {
  let metaProviderPath = shared.path.normal(series.providerName + shared.extension.json);
  let metaProviderExists = await fs.pathExists(metaProviderPath);
  let metaProvider = metaProviderExists ? await fs.readJson(metaProviderPath) as shared.IMetaProvider : {};
  metaProvider[series.url] = series.title;
  await mio.commands.updateSeriesAsync(series);
  await fs.writeJson(metaProviderPath, metaProvider, {spaces: 2});
}
开发者ID:Deathspike,项目名称:mangarack,代码行数:8,代码来源:create.ts


示例6: execAsync

export async function execAsync(argv: string[]) {
  let packageData = await fs.readJson(packagePath);
  commander.version(packageData.version);
  commander.option('--no-webpack', 'disables webpack middleware');
  commander.option('-p, --port <n>', 'sets the port', parseInt);
  commander.parse(argv);
  await mio.serveAsync(commander.port || mio.settings.serverPort, commander.webpack);
}
开发者ID:Deathspike,项目名称:mangarack,代码行数:8,代码来源:exec.ts


示例7: getPackageJSON

/**
 * Return package.json object
 *
 * @param {string} projectPath
 * @returns
 */
async function getPackageJSON(projectPath: string) {
  const packageJSONPath = path.join(projectPath, 'package.json');
  const fileExists = await fs.exists(packageJSONPath);
  if (!fileExists) {
    throw new Error(`The project doesn't have a package.json.`);
  }

  return fs.readJson(packageJSONPath);
}
开发者ID:ghoullier,项目名称:codesandbox-cli,代码行数:15,代码来源:index.ts


示例8: readPackageJson

export async function readPackageJson(dir: string, safe = false) {
  try {
    return await fs.readJson(path.resolve(dir, 'package.json'));
  } catch (err) {
    if (safe) {
      return {};
    } else {
      throw err;
    }
  }
}
开发者ID:electron,项目名称:electron-rebuild,代码行数:11,代码来源:read-package-json.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
TypeScript fs-extra.readJsonSync函数代码示例发布时间:2022-05-25
下一篇:
TypeScript fs-extra.readJSONSync函数代码示例发布时间: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