How to use the npm-check-updates.upgradeDependencies function in npm-check-updates

To help you get started, we’ve selected a few npm-check-updates 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 th0r / npm-upgrade / src / commands / check.js View on Github external
const depsGroupsToCheck = _.filter(DEPS_GROUPS, ({name}) => !!opts[name]);
  const depsGroupsToCheckStr = (depsGroupsToCheck.length === DEPS_GROUPS.length) ?
    '' : `${toSentence(_.map(depsGroupsToCheck, ({name}) => strong(name)))} `;
  const filteredWith = filter ? `filtered with ${strong(filter)} ` : '';

  console.log(
    `Checking for outdated ${depsGroupsToCheckStr}dependencies ${filteredWith}for "${strong(packageFile)}"...`
  );

  const ncuDepGroups = DEPS_GROUPS
    .filter(({name}) => opts[name])
    .map(({ncuValue}) => ncuValue)
    .join(',');
  const currentVersions = ncu.getCurrentDependencies(packageJson, {dep: ncuDepGroups});
  const latestVersions = await ncu.queryVersions(currentVersions, {versionTarget: 'latest'});
  let upgradedVersions = ncu.upgradeDependencies(currentVersions, latestVersions);

  // Filtering modules that have to be updated
  upgradedVersions = _.pickBy(
    upgradedVersions,
    (newVersion, moduleName) => filterModuleName(moduleName)
  );

  if (_.isEmpty(upgradedVersions)) {
    return console.log(success('All dependencies are up-to-date!'));
  }

  // Getting the list of ignored modules
  const config = new Config();
  config.ignore = config.ignore || {};

  // Making arrays of outdated modules

npm-check-updates

Find newer versions of dependencies than what your package.json allows

Apache-2.0
Latest version published 9 days ago

Package Health Score

95 / 100
Full package analysis