How to use preferred-pm - 1 common examples

To help you get started, we’ve selected a few preferred-pm 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 art-software / art-core / packages / art-cli-tool / src / helpers / npmUpdate.ts View on Github external
let bin;
  if (process.env.STAGE === Stage.dev) {
    bin = join(__dirname, '../../../../node_modules/.bin/npm-check');
  } else {
    const npmCheckPathOne = join(__dirname, '../../../npm-check-support-yarn/bin/cli.js');
    const npmCheckPathTwo = join(__dirname, '../../node_modules/npm-check-support-yarn/bin/cli.js');
    if (existsSync(npmCheckPathOne)) {
      bin = npmCheckPathOne;
    } else if (existsSync(npmCheckPathTwo)) {
      bin = npmCheckPathTwo;
    } else {
      throw new Error('No npm-check package found globally');
    }
  }

  preferredPm(process.cwd())
    .then((pm) => {
      const pmName = pm.name;
      const env = Object.create( process.env );
      env.UPDATE_INSTALLER = pmName;
      const child = spawn(
        bin,
        [
          '--update',
          '--ignore', notArtPkgGlob,
          '--skip-unused'
        ],
        {
          stdio: 'inherit',
          env
        }
      );

preferred-pm

Detects what package manager was used for installation

MIT
Latest version published 6 months ago

Package Health Score

76 / 100
Full package analysis

Popular preferred-pm functions