mirror of
https://github.com/nodejs/node.git
synced 2025-08-20 01:15:51 +02:00
deps: update npm to 7.0.0-rc.3
PR-URL: https://github.com/nodejs/node/pull/35474 Reviewed-By: Ruy Adorno <ruyadorno@github.com> Reviewed-By: Ujjwal Sharma <ryzokuken@disroot.org> Reviewed-By: Ben Coe <bencoe@gmail.com> Reviewed-By: Geoffrey Booth <webmaster@geoffreybooth.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Shelley Vohr <codebytere@gmail.com> Reviewed-By: Guy Bedford <guybedford@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
This commit is contained in:
parent
1469984645
commit
2e54524955
4238 changed files with 192906 additions and 296892 deletions
65
deps/npm/node_modules/@npmcli/run-script/lib/run-script-pkg.js
generated
vendored
Normal file
65
deps/npm/node_modules/@npmcli/run-script/lib/run-script-pkg.js
generated
vendored
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
const makeSpawnArgs = require('./make-spawn-args.js')
|
||||
const promiseSpawn = require('@npmcli/promise-spawn')
|
||||
const packageEnvs = require('./package-envs.js')
|
||||
const { isNodeGypPackage, defaultGypInstallScript } = require('@npmcli/node-gyp')
|
||||
|
||||
// you wouldn't like me when I'm angry...
|
||||
const bruce = (id, event, cmd) => `\n> ${id ? id + ' ' : ''}${event}\n> ${cmd}\n`
|
||||
|
||||
const runScriptPkg = async options => {
|
||||
const {
|
||||
event,
|
||||
path,
|
||||
scriptShell,
|
||||
env = {},
|
||||
stdio = 'pipe',
|
||||
pkg,
|
||||
args = [],
|
||||
stdioString = false,
|
||||
// note: only used when stdio:inherit
|
||||
banner = true,
|
||||
} = options
|
||||
|
||||
const {scripts = {}, gypfile} = pkg
|
||||
let cmd = null
|
||||
if (options.cmd)
|
||||
cmd = options.cmd
|
||||
else if (pkg.scripts && pkg.scripts[event])
|
||||
cmd = pkg.scripts[event] + args.map(a => ` ${JSON.stringify(a)}`).join('')
|
||||
else if ( // If there is no preinstall or install script, default to rebuilding node-gyp packages.
|
||||
event === 'install' &&
|
||||
!scripts.install &&
|
||||
!scripts.preinstall &&
|
||||
gypfile !== false &&
|
||||
await isNodeGypPackage(path)
|
||||
)
|
||||
cmd = defaultGypInstallScript
|
||||
|
||||
if (!cmd)
|
||||
return { code: 0, signal: null }
|
||||
|
||||
if (stdio === 'inherit' && banner !== false) {
|
||||
// we're dumping to the parent's stdout, so print the banner
|
||||
console.log(bruce(pkg._id, event, cmd))
|
||||
}
|
||||
|
||||
const p = promiseSpawn(...makeSpawnArgs({
|
||||
event,
|
||||
path,
|
||||
scriptShell,
|
||||
env: packageEnvs(env, pkg),
|
||||
stdio,
|
||||
cmd,
|
||||
stdioString,
|
||||
}), {
|
||||
event,
|
||||
script: cmd,
|
||||
pkgid: pkg._id,
|
||||
path,
|
||||
})
|
||||
if (p.stdin)
|
||||
p.stdin.end()
|
||||
return p
|
||||
}
|
||||
|
||||
module.exports = runScriptPkg
|
||||
Loading…
Add table
Add a link
Reference in a new issue