How to use the read-pkg function in read-pkg

To help you get started, we’ve selected a few read-pkg examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github project-flogo / flogo-web / tools / release / post-build-apps.js View on Github external
async function updatePkgJson(from, to) {
  const pkgJson = await readPkg({ cwd: from });
  pkgJson.version = process.env.FLOGO_LIB_VERSION || `dev-${pkgJson.version}`;
  await writePkg(to, pkgJson);
}
github vladshcherbin / rollup-plugin-generate-package-json / src / index.js View on Github external
async function readPackageJson(folder) {
  try {
    return await readPackage({ normalize: false, ...(folder && { cwd: folder }) })
  } catch (e) {
    throw new Error('Input package.json file does not exist or has bad format, check "inputFolder" option')
  }
}
github elastic / kibana / packages / kbn-pm / src / utils / package_json.ts View on Github external
export function readPackageJson(cwd: string): IPackageJson {
  return readPkg({ cwd, normalize: false });
}
github asfktz / autodll-webpack-plugin / src / validateCache.js View on Github external
const validateCache = settings => {
  const prevPkgPath = path.join(cacheDir, 'package.json.hash');

  return Promise.all([
    fs.lstatAsync(path.join(cacheDir, settings.hash)).catch(() => null),
    fs.readFileAsync(prevPkgPath).catch(() => null),
    readPkg(settings.context).catch(() => null),
  ]).then(([buildHashDirExist, prevPkgHash, pkg]) => {
    const pkgHash = JSON.stringify(pkg);

    if (buildHashDirExist && (prevPkgHash && prevPkgHash.toString() === pkgHash)) {
      return true;
    }

    return makeDir(cacheDir)
      .then(() => fs.writeFileAsync(prevPkgPath, pkgHash))
      .then(() => false);
  });
};

read-pkg

Read a package.json file

MIT
Latest version published 5 months ago

Package Health Score

76 / 100
Full package analysis

Popular read-pkg functions