@npmcli/run-script
Advanced tools
Comparing version 4.1.7 to 4.2.0
@@ -23,2 +23,3 @@ /* eslint camelcase: "off" */ | ||
scriptShell = isWindows ? process.env.ComSpec || 'cmd' : 'sh', | ||
binPaths, | ||
env = {}, | ||
@@ -31,3 +32,3 @@ stdio, | ||
const spawnEnv = setPATH(path, { | ||
const spawnEnv = setPATH(path, binPaths, { | ||
// we need to at least save the PATH environment var | ||
@@ -105,3 +106,5 @@ ...process.env, | ||
unlink(scriptFile) | ||
} catch (err) {} | ||
} catch (err) { | ||
// ignore errors | ||
} | ||
} | ||
@@ -108,0 +111,0 @@ |
@@ -17,2 +17,3 @@ const makeSpawnArgs = require('./make-spawn-args.js') | ||
scriptShell, | ||
binPaths = false, | ||
env = {}, | ||
@@ -62,2 +63,3 @@ stdio = 'pipe', | ||
scriptShell, | ||
binPaths, | ||
env: packageEnvs(env, pkg), | ||
@@ -64,0 +66,0 @@ stdio, |
@@ -1,3 +0,2 @@ | ||
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 | ||
@@ -10,5 +9,3 @@ // in order to make the posix tests pass in windows | ||
// 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]) | ||
@@ -20,5 +17,8 @@ .map(p => env[p].split(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 | ||
@@ -25,0 +25,0 @@ let pp |
{ | ||
"name": "@npmcli/run-script", | ||
"version": "4.1.7", | ||
"version": "4.2.0", | ||
"description": "Run a lifecycle script for a package (descendant of npm-lifecycle)", | ||
@@ -5,0 +5,0 @@ "author": "GitHub Inc.", |
@@ -20,2 +20,12 @@ # @npmcli/run-script | ||
// optional, these paths will be put at the beginning of `$PATH`, even | ||
// after run-script adds the node_modules/.bin folder(s) from | ||
// `process.cwd()`. This is for commands like `npm init`, `npm exec`, | ||
// and `npx` to make sure manually installed packages come before | ||
// anything that happens to be in the tree in `process.cwd()`. | ||
binPaths: [ | ||
'/path/to/npx/node_modules/.bin', | ||
'/path/to/npm/prefix/node_modules/.bin', | ||
] | ||
// optional, defaults to /bin/sh on unix, or cmd.exe on windows | ||
@@ -22,0 +32,0 @@ scriptShell: '/bin/bash', |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
21735
414
175