From d0be9a2bb53e74b30e13751afd1f6924990c8422 Mon Sep 17 00:00:00 2001 From: Gar Date: Mon, 1 Aug 2022 10:12:34 -0700 Subject: [PATCH] deps: @npmcli/run-script@4.2.0 - add `binPaths` param --- .../@npmcli/run-script/lib/make-spawn-args.js | 7 +++++-- .../@npmcli/run-script/lib/run-script-pkg.js | 2 ++ node_modules/@npmcli/run-script/lib/set-path.js | 12 ++++++------ node_modules/@npmcli/run-script/package.json | 2 +- package-lock.json | 10 +++++----- package.json | 2 +- workspaces/libnpmexec/package.json | 2 +- 7 files changed, 21 insertions(+), 16 deletions(-) diff --git a/node_modules/@npmcli/run-script/lib/make-spawn-args.js b/node_modules/@npmcli/run-script/lib/make-spawn-args.js index f2253d7cc607b..7725fd976c893 100644 --- a/node_modules/@npmcli/run-script/lib/make-spawn-args.js +++ b/node_modules/@npmcli/run-script/lib/make-spawn-args.js @@ -20,6 +20,7 @@ const makeSpawnArgs = options => { event, path, scriptShell = isWindows ? process.env.ComSpec || 'cmd' : 'sh', + binPaths, env = {}, stdio, cmd, @@ -27,7 +28,7 @@ const makeSpawnArgs = options => { stdioString = false, } = options - const spawnEnv = setPATH(path, { + const spawnEnv = setPATH(path, binPaths, { // we need to at least save the PATH environment var ...process.env, ...env, @@ -100,7 +101,9 @@ const makeSpawnArgs = options => { // delete the script, this is just a best effort try { unlink(scriptFile) - } catch (err) {} + } catch (err) { + // ignore errors + } } return [scriptShell, spawnArgs, spawnOpts, cleanup] diff --git a/node_modules/@npmcli/run-script/lib/run-script-pkg.js b/node_modules/@npmcli/run-script/lib/run-script-pkg.js index 84c5e2bfe0c52..ec6ef31e50ab0 100644 --- a/node_modules/@npmcli/run-script/lib/run-script-pkg.js +++ b/node_modules/@npmcli/run-script/lib/run-script-pkg.js @@ -14,6 +14,7 @@ const runScriptPkg = async options => { event, path, scriptShell, + binPaths = false, env = {}, stdio = 'pipe', pkg, @@ -58,6 +59,7 @@ const runScriptPkg = async options => { event, path, scriptShell, + binPaths, env: packageEnvs(env, pkg), stdio, cmd, diff --git a/node_modules/@npmcli/run-script/lib/set-path.js b/node_modules/@npmcli/run-script/lib/set-path.js index 07671f44579dc..c59c270d9969a 100644 --- a/node_modules/@npmcli/run-script/lib/set-path.js +++ b/node_modules/@npmcli/run-script/lib/set-path.js @@ -1,5 +1,4 @@ -const { resolve, dirname } = require('path') -const isWindows = require('./is-windows.js') +const { resolve, dirname, delimiter } = require('path') // the path here is relative, even though it does not need to be // in order to make the posix tests pass in windows const nodeGypPath = resolve(__dirname, '../lib/node-gyp-bin') @@ -7,18 +6,19 @@ const nodeGypPath = resolve(__dirname, '../lib/node-gyp-bin') // Windows typically calls its PATH environ 'Path', but this is not // guaranteed, nor is it guaranteed to be the only one. Merge them // all together in the order they appear in the object. -const setPATH = (projectPath, env) => { - // not require('path').delimiter, because we fake this for testing - const delimiter = isWindows ? ';' : ':' +const setPATH = (projectPath, binPaths, env) => { const PATH = Object.keys(env).filter(p => /^path$/i.test(p) && env[p]) .map(p => env[p].split(delimiter)) .reduce((set, p) => set.concat(p.filter(concatted => !set.includes(concatted))), []) .join(delimiter) const pathArr = [] + if (binPaths) { + pathArr.push(...binPaths) + } // unshift the ./node_modules/.bin from every folder // walk up until dirname() does nothing, at the root - // XXX should we specify a cwd that we don't go above? + // XXX we should specify a cwd that we don't go above let p = projectPath let pp do { diff --git a/node_modules/@npmcli/run-script/package.json b/node_modules/@npmcli/run-script/package.json index c096f39421bf1..a6629826d29c2 100644 --- a/node_modules/@npmcli/run-script/package.json +++ b/node_modules/@npmcli/run-script/package.json @@ -1,6 +1,6 @@ { "name": "@npmcli/run-script", - "version": "4.1.7", + "version": "4.2.0", "description": "Run a lifecycle script for a package (descendant of npm-lifecycle)", "author": "GitHub Inc.", "license": "ISC", diff --git a/package-lock.json b/package-lock.json index 16e153b1dad9d..4a952e2ff5e50 100644 --- a/package-lock.json +++ b/package-lock.json @@ -94,7 +94,7 @@ "@npmcli/fs": "^2.1.0", "@npmcli/map-workspaces": "^2.0.3", "@npmcli/package-json": "^2.0.0", - "@npmcli/run-script": "^4.1.7", + "@npmcli/run-script": "^4.2.0", "abbrev": "~1.1.1", "archy": "~1.0.0", "cacache": "^16.1.1", @@ -1057,9 +1057,9 @@ } }, "node_modules/@npmcli/run-script": { - "version": "4.1.7", - "resolved": "https://registry.npmjs.org/@npmcli/run-script/-/run-script-4.1.7.tgz", - "integrity": "sha512-WXr/MyM4tpKA4BotB81NccGAv8B48lNH0gRoILucbcAhTQXLCoi6HflMV3KdXubIqvP9SuLsFn68Z7r4jl+ppw==", + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/@npmcli/run-script/-/run-script-4.2.0.tgz", + "integrity": "sha512-e/QgLg7j2wSJp1/7JRl0GC8c7PMX+uYlA/1Tb+IDOLdSM4T7K1VQ9mm9IGU3WRtY5vEIObpqCLb3aCNCug18DA==", "inBundle": true, "dependencies": { "@npmcli/node-gyp": "^2.0.0", @@ -10137,7 +10137,7 @@ "@npmcli/arborist": "^5.0.0", "@npmcli/ci-detect": "^2.0.0", "@npmcli/fs": "^2.1.1", - "@npmcli/run-script": "^4.1.3", + "@npmcli/run-script": "^4.2.0", "chalk": "^4.1.0", "mkdirp-infer-owner": "^2.0.0", "npm-package-arg": "^9.0.1", diff --git a/package.json b/package.json index 7526c4754b0ff..1adb37652a075 100644 --- a/package.json +++ b/package.json @@ -62,7 +62,7 @@ "@npmcli/fs": "^2.1.0", "@npmcli/map-workspaces": "^2.0.3", "@npmcli/package-json": "^2.0.0", - "@npmcli/run-script": "^4.1.7", + "@npmcli/run-script": "^4.2.0", "abbrev": "~1.1.1", "archy": "~1.0.0", "cacache": "^16.1.1", diff --git a/workspaces/libnpmexec/package.json b/workspaces/libnpmexec/package.json index 58c546fc2c8d9..349e82715f9af 100644 --- a/workspaces/libnpmexec/package.json +++ b/workspaces/libnpmexec/package.json @@ -58,7 +58,7 @@ "@npmcli/arborist": "^5.0.0", "@npmcli/ci-detect": "^2.0.0", "@npmcli/fs": "^2.1.1", - "@npmcli/run-script": "^4.1.3", + "@npmcli/run-script": "^4.2.0", "chalk": "^4.1.0", "mkdirp-infer-owner": "^2.0.0", "npm-package-arg": "^9.0.1",