codekingpro/portable-devtools
114k
1// run an npm command
2const spawn = require('@npmcli/promise-spawn')
3
4module.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
13 return spawn(cmd, args, { cwd, env }, extra)
14}
15 