当前位置: 首页>>代码示例>>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;未经允许,请勿转载。