當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。