Skip to content

Commit 12b2b87

Browse files
committed
Breaking: use NPM_EXECPATH to run tasks
And add --npm-path option.
1 parent 07bfec5 commit 12b2b87

File tree

15 files changed

+98
-9
lines changed

15 files changed

+98
-9
lines changed

bin/common/parse-cli-args.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,17 +77,18 @@ class ArgumentSet {
7777
* @param {object} options - A key-value map for the options.
7878
*/
7979
constructor(initialValues, options) {
80+
this.config = {}
8081
this.continueOnError = false
8182
this.groups = []
8283
this.maxParallel = 0
84+
this.npmPath = null
85+
this.packageConfig = createPackageConfig()
8386
this.printLabel = false
8487
this.printName = false
8588
this.race = false
8689
this.rest = []
8790
this.silent = process.env.npm_config_loglevel === "silent"
8891
this.singleMode = Boolean(options && options.singleMode)
89-
this.packageConfig = createPackageConfig()
90-
this.config = {}
9192

9293
addGroup(this.groups, initialValues)
9394
}
@@ -181,6 +182,10 @@ function parseCLIArgsCore(set, args) { // eslint-disable-line complexity
181182
addGroup(set.groups, {parallel: true})
182183
break
183184

185+
case "--npm-path":
186+
set.npmPath = args[++i] || null
187+
break
188+
184189
default: {
185190
let matched = null
186191
if ((matched = OVERWRITE_OPTION.exec(arg))) {

bin/npm-run-all/help.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ Options:
3333
non-zero code if one or more tasks threw error(s)
3434
--max-parallel <number> - Set the maximum number of parallelism. Default is
3535
unlimited.
36+
--npm-path <string> - - - Set the path to npm. Default is the value of
37+
environment variable NPM_EXECPATH.
38+
If the variable is not defined, then it's "npm."
39+
In this case, the "npm" command must be found in
40+
environment variable PATH.
3641
-l, --print-label - - - - Set the flag to print the task name as a prefix
3742
on each line of output. Tools in tasks may stop
3843
coloring their output if this option was given.

bin/npm-run-all/main.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ module.exports = function npmRunAll(args, stdout, stderr) {
5151
silent: argv.silent,
5252
arguments: argv.rest,
5353
race: argv.race,
54+
npmPath: argv.npmPath,
5455
}
5556
))
5657
},

bin/run-p/help.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ Options:
3333
threw error(s).
3434
--max-parallel <number> - Set the maximum number of parallelism. Default is
3535
unlimited.
36+
--npm-path <string> - - - Set the path to npm. Default is the value of
37+
environment variable NPM_EXECPATH.
38+
If the variable is not defined, then it's "npm."
39+
In this case, the "npm" command must be found in
40+
environment variable PATH.
3641
-l, --print-label - - - - Set the flag to print the task name as a prefix
3742
on each line of output. Tools in tasks may stop
3843
coloring their output if this option was given.

bin/run-p/main.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ module.exports = function npmRunAll(args, stdout, stderr) {
5151
silent: argv.silent,
5252
arguments: argv.rest,
5353
race: argv.race,
54+
npmPath: argv.npmPath,
5455
}
5556
)
5657

bin/run-s/help.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ Options:
3131
tasks even if a task threw an error. 'run-s'
3232
itself will exit with non-zero code if one or
3333
more tasks threw error(s).
34+
--npm-path <string> - - - Set the path to npm. Default is the value of
35+
environment variable NPM_EXECPATH.
36+
If the variable is not defined, then it's "npm."
37+
In this case, the "npm" command must be found in
38+
environment variable PATH.
3439
-l, --print-label - - - - Set the flag to print the task name as a prefix
3540
on each line of output. Tools in tasks may stop
3641
coloring their output if this option was given.

bin/run-s/main.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ module.exports = function npmRunAll(args, stdout, stderr) {
4949
packageConfig: argv.packageConfig,
5050
silent: argv.silent,
5151
arguments: argv.rest,
52+
npmPath: argv.npmPath,
5253
}
5354
)
5455

docs/node-api.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ Run npm-scripts.
4848
- **options.maxParallel** `number` --
4949
The maximum number of parallelism.
5050
Default is `Number.POSITIVE_INFINITY`.
51+
- **options.npmPath** `string` --
52+
The path to npm.
53+
Default is `process.env.NPM_EXECPATH` or `"npm"`.
5154
- **options.packageConfig** `object|null` --
5255
The map-like object to overwrite package configs.
5356
Keys are package names.

docs/npm-run-all.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ Options:
3838
non-zero code if one or more tasks threw error(s)
3939
--max-parallel <number> - Set the maximum number of parallelism. Default is
4040
unlimited.
41+
--npm-path <string> - - - Set the path to npm. Default is the value of
42+
environment variable NPM_EXECPATH.
43+
If the variable is not defined, then it's "npm."
44+
In this case, the "npm" command must be found in
45+
environment variable PATH.
4146
-l, --print-label - - - - Set the flag to print the task name as a prefix
4247
on each line of output. Tools in tasks may stop
4348
coloring their output if this option was given.

docs/run-p.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ Options:
3737
threw error(s).
3838
--max-parallel <number> - Set the maximum number of parallelism. Default is
3939
unlimited.
40+
--npm-path <string> - - - Set the path to npm. Default is the value of
41+
environment variable NPM_EXECPATH.
42+
If the variable is not defined, then it's "npm."
43+
In this case, the "npm" command must be found in
44+
environment variable PATH.
4045
-l, --print-label - - - - Set the flag to print the task name as a prefix
4146
on each line of output. Tools in tasks may stop
4247
coloring their output if this option was given.

0 commit comments

Comments
 (0)