Skip to content

Commit 7a5df84

Browse files
Ransom Briggsbestander
authored andcommitted
Add scripts-prepend-node-path flag (#3511)
1 parent 3299509 commit 7a5df84

File tree

3 files changed

+8
-0
lines changed

3 files changed

+8
-0
lines changed

src/cli/index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ commander.option('--no-progress', 'disable progress bar');
6666
commander.option('--network-concurrency <number>', 'maximum number of concurrent network requests', parseInt);
6767
commander.option('--network-timeout <milliseconds>', 'TCP timeout for network requests', parseInt);
6868
commander.option('--non-interactive', 'do not show interactive prompts');
69+
commander.option('--scripts-prepend-node-path [bool]', 'prepend the node executable dir to the PATH in scripts');
6970

7071
// get command name
7172
let commandName: string = args.shift() || 'install';
@@ -305,6 +306,8 @@ config
305306
networkConcurrency: commander.networkConcurrency,
306307
networkTimeout: commander.networkTimeout,
307308
nonInteractive: commander.nonInteractive,
309+
scriptsPrependNodePath: commander.scriptsPrependNodePath,
310+
308311
commandName: commandName === 'run' ? commander.args[0] : commandName,
309312
})
310313
.then(() => {

src/config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ export type ConfigOptions = {
4444
childConcurrency?: number,
4545
networkTimeout?: number,
4646
nonInteractive?: boolean,
47+
scriptsPrependNodePath?: boolean,
4748

4849
// Loosely compare semver for invalid cases like "0.01.0"
4950
looseSemver?: ?boolean,

src/util/execute-lifecycle-script.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,10 @@ export async function executeLifecycleScript(
154154

155155
await checkForGypIfNeeded(config, cmd, pathParts);
156156

157+
if (config.scriptsPrependNodePath) {
158+
pathParts.unshift(path.join(path.dirname(process.execPath)));
159+
}
160+
157161
// join path back together
158162
env[constants.ENV_PATH_KEY] = pathParts.join(path.delimiter);
159163

0 commit comments

Comments
 (0)