index.js 456 B

1234567891011
  1. 'use strict';
  2. const packageJson = process.env.npm_package_json;
  3. const userAgent = process.env.npm_config_user_agent;
  4. const isYarn = Boolean(userAgent && userAgent.startsWith('yarn'));
  5. const isNpm = Boolean(userAgent && userAgent.startsWith('npm'));
  6. const isNpm7 = Boolean(packageJson && packageJson.endsWith('package.json'));
  7. module.exports.isNpmOrYarn = isNpm || isNpm7 || isYarn;
  8. module.exports.isNpm = isNpm || isNpm7;
  9. module.exports.isYarn = isYarn;