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


TypeScript fs-extra.writeJson函數代碼示例

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


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

示例1: it

 it('throws an error when all is set', async () => {
   let packageJSON = await readRawPackageJson(dir);
   packageJSON.config.forge.packagerConfig.all = true;
   await fs.writeJson(path.join(dir, 'package.json'), packageJSON);
   await expect(forge.package({ dir })).to.eventually.be.rejectedWith(/packagerConfig\.all is not supported by Electron Forge/);
   packageJSON = await readRawPackageJson(dir);
   delete packageJSON.config.forge.packagerConfig.all;
   await fs.writeJson(path.join(dir, 'package.json'), packageJSON);
 });
開發者ID:balloonzzq,項目名稱:electron-forge,代碼行數:9,代碼來源:api_spec_slow.ts

示例2: readMutatedPackageJson

 afterCopyHooks.push(async (buildPath, electronVersion, pPlatform, pArch, done) => {
   const copiedPackageJSON = await readMutatedPackageJson(buildPath, forgeConfig);
   if (copiedPackageJSON.config && copiedPackageJSON.config.forge) {
     delete copiedPackageJSON.config.forge;
   }
   await fs.writeJson(path.resolve(buildPath, 'package.json'), copiedPackageJSON, { spaces: 2 });
   done();
 });
開發者ID:balloonzzq,項目名稱:electron-forge,代碼行數:8,代碼來源:package.ts

示例3: updateSeriesAsync

export async function updateSeriesAsync(series: mio.IScraperSeries) {
  let seriesImage = await series.imageAsync();
  let metaSeriesPath = shared.path.normal(series.providerName, series.title + shared.extension.json);
  let metaSeries = transformMetadata(series, seriesImage);
  await fs.ensureDir(path.dirname(metaSeriesPath));
  await fs.writeJson(metaSeriesPath, metaSeries, {spaces: 2})
  return true;
}
開發者ID:Deathspike,項目名稱:mangarack,代碼行數:8,代碼來源:update.ts

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

示例5: asyncOra

  await asyncOra('Initializing NPM Module', async () => {
    const packageJSON = await readPackageJSON(path.resolve(__dirname, '../../../tmpl'));
    packageJSON.productName = packageJSON.name = path.basename(dir).toLowerCase();
    packageJSON.author = await username();
    setInitialForgeConfig(packageJSON);

    packageJSON.scripts.lint = 'echo "No linting configured"';

    d('writing package.json to:', dir);
    await fs.writeJson(path.resolve(dir, 'package.json'), packageJSON, { spaces: 2 });
  });
開發者ID:jangocheng,項目名稱:electron-forge,代碼行數:11,代碼來源:init-npm.ts

示例6: generatePackageJson

/**
 * Generate a super minimal package.json from an existing bower.json, and adds
 * `node_modules` to `.gitignore` if needed. Does nothing if there's already a
 * package.json.
 */
async function generatePackageJson(element: ElementRepo): Promise<void> {
  const npmConfigPath = path.join(element.dir, 'package.json');
  if (await fse.pathExists(npmConfigPath)) {
    console.log(`${element.ghRepo.name} already has a package.json, skipping.`);
    return;
  }

  const bowerConfigPath = path.join(element.dir, 'bower.json');
  if (!await fse.pathExists(bowerConfigPath)) {
    throw new Error(`${element.ghRepo.name} has no bower.json.`);
  }
  const bowerConfig: BowerConfig = await fse.readJson(bowerConfigPath);

  const npmConfig: NpmConfig = {
    // This is the style of name we're using for the 3.0 elements on NPM. Might
    // as well be consistent, even though this is a 2.0 package.json.
    name: `@polymer/${bowerConfig.name}`,

    // Make sure we don't accidentally publish this repo.
    private: true,

    // Note that we exclude version because the bower version might not be well
    // maintained, plus it won't get updated here going forward if we do more
    // releases.

    // npm warns if any of these fields aren't set.
    description: bowerConfig.description,
    repository: bowerConfig.repository,
    license: 'BSD-3-Clause'
  };

  // Since we're an NPM package now, we might get some dependencies installed,
  // which we don't want to commit.
  const gitIgnorePath = path.join(element.dir, '.gitignore');
  let gitIgnore = '';
  if (await fse.pathExists(gitIgnorePath)) {
    gitIgnore = (await fse.readFile(gitIgnorePath)).toString();
  }
  if (!gitIgnore.includes('node_modules')) {
    if (!gitIgnore.endsWith('\n')) {
      gitIgnore += '\n';
    }
    gitIgnore += 'node_modules\n';
    await fse.writeFile(gitIgnorePath, gitIgnore);
  }

  await fse.writeJson(npmConfigPath, npmConfig, {spaces: 2});

  await makeCommit(
      element,
      ['package.json', '.gitignore'],
      'Generate minimal package.json from bower.json');
}
開發者ID:TimvdLippe,項目名稱:tedium,代碼行數:58,代碼來源:package-json.ts

示例7: function

export default async function({ dry, pkg }) {
  const memoGetDependants = memo(getDependants);

  for (const w of await getWorkspaces()) {
    const wName = w.name;
    const wVersion = w.config.version;
    const deps = await memoGetDependants(w.name);

    if (!deps.length) {
      continue;
    }

    const logger = logOnce();
    for (const dep of deps) {
      if (pkg && pkg !== dep) {
        continue;
      }

      const depw = await getWorkspace(dep);
      const depwConf = depw.config;
      const depwDeps = depwConf.dependencies;
      const depwDevs = depwConf.devDependencies;
      const depwOpts = depwConf.optionalDependencies;
      const depwPeer = depwConf.peerDependencies;
      const depwMerged = { ...depwDeps, ...depwDevs, ...depwOpts, ...depwPeer };

      updateVersion(wName, wVersion, depwDeps);
      updateVersion(wName, wVersion, depwDevs);
      updateVersion(wName, wVersion, depwOpts);
      updateVersion(wName, wVersion, depwPeer);

      if (depwMerged[wName] !== wVersion) {
        logger(EOL + wName);
        console.log(`  ${depw.name}: ${depwMerged[wName]} -> ${wVersion}`);

        if (!dry) {
          writeJson(path.join(depw.dir, 'package.json'), depwConf, {
            spaces: 2
          });
        }
      }
    }
  }
}
開發者ID:skatejs,項目名稱:skatejs,代碼行數:44,代碼來源:bump.ts


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