npm.js 620 B

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