diff options
author | npm CLI robot <npm-cli+bot@github.com> | 2022-07-19 08:51:49 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-19 16:51:49 +0100 |
commit | dd167ff0ee90fa47e0d92c514c20f1aaa53363bc (patch) | |
tree | 6044cf73f389bbdb97c6540bc9604012824e2fb8 /deps/npm/node_modules/@npmcli/run-script/lib/make-spawn-args.js | |
parent | 8657d6db0703d57912e489707a8d4a40c233dfdc (diff) | |
download | node-new-dd167ff0ee90fa47e0d92c514c20f1aaa53363bc.tar.gz |
deps: upgrade npm to 8.14.0
PR-URL: https://github.com/nodejs/node/pull/43826
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Diffstat (limited to 'deps/npm/node_modules/@npmcli/run-script/lib/make-spawn-args.js')
-rw-r--r-- | deps/npm/node_modules/@npmcli/run-script/lib/make-spawn-args.js | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/deps/npm/node_modules/@npmcli/run-script/lib/make-spawn-args.js b/deps/npm/node_modules/@npmcli/run-script/lib/make-spawn-args.js index 47f7346301..f2253d7cc6 100644 --- a/deps/npm/node_modules/@npmcli/run-script/lib/make-spawn-args.js +++ b/deps/npm/node_modules/@npmcli/run-script/lib/make-spawn-args.js @@ -1,12 +1,19 @@ /* eslint camelcase: "off" */ const isWindows = require('./is-windows.js') const setPATH = require('./set-path.js') -const { chmodSync: chmod, unlinkSync: unlink, writeFileSync: writeFile } = require('fs') +const { unlinkSync: unlink, writeFileSync: writeFile } = require('fs') const { tmpdir } = require('os') -const { isAbsolute, resolve } = require('path') +const { resolve } = require('path') const which = require('which') const npm_config_node_gyp = require.resolve('node-gyp/bin/node-gyp.js') const escape = require('./escape.js') +const { randomBytes } = require('crypto') + +const translateWinPathToPosix = (path) => { + return path + .replace(/^([A-z]):/, '/$1') + .replace(/\\/g, '/') +} const makeSpawnArgs = options => { const { @@ -30,7 +37,7 @@ const makeSpawnArgs = options => { npm_config_node_gyp, }) - const fileName = escape.filename(`${event}-${Date.now()}`) + const fileName = escape.filename(`${event}-${randomBytes(4).toString('hex')}`) let scriptFile let script = '' @@ -69,24 +76,17 @@ const makeSpawnArgs = options => { script += ` ${args.map((arg) => escape.cmd(arg, doubleEscape)).join(' ')}` } } else { - const shebang = isAbsolute(scriptShell) - ? `#!${scriptShell}` - : `#!/usr/bin/env ${scriptShell}` scriptFile = resolve(tmpdir(), `${fileName}.sh`) - script += `${shebang}\n` - script += cmd + script = cmd if (args.length) { script += ` ${args.map((arg) => escape.sh(arg)).join(' ')}` } } writeFile(scriptFile, script) - if (!isCmd) { - chmod(scriptFile, '0775') - } const spawnArgs = isCmd ? ['/d', '/s', '/c', escape.cmd(scriptFile)] - : ['-c', escape.sh(scriptFile)] + : [isWindows ? translateWinPathToPosix(scriptFile) : scriptFile] const spawnOpts = { env: spawnEnv, |