当前位置: 首页>>代码示例>>TypeScript>>正文


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

本文整理汇总了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;未经允许,请勿转载。