npm.js 567 B

1234567891011121314
  1. // run an npm command
  2. const spawn = require('@npmcli/promise-spawn')
  3. module.exports = (npmBin, npmCommand, cwd, env, extra) => {
  4. const isJS = npmBin.endsWith('.js')
  5. const cmd = isJS ? process.execPath : npmBin
  6. const args = (isJS ? [npmBin] : []).concat(npmCommand)
  7. // when installing to run the `prepare` script for a git dep, we need
  8. // to ensure that we don't run into a cycle of checking out packages
  9. // in temp directories. this lets us link previously-seen repos that
  10. // are also being prepared.
  11. return spawn(cmd, args, { cwd, env }, extra)
  12. }