Skip to content

Commit 1017d3b

Browse files
committed
fixup: allow for nodeGyp to be passed as an option
1 parent 989cb6f commit 1017d3b

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

lib/make-spawn-args.js

+13-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
/* eslint camelcase: "off" */
22
const setPATH = require('./set-path.js')
33
const { resolve } = require('path')
4-
const npm_config_node_gyp = require.resolve('node-gyp/bin/node-gyp.js')
54

65
const makeSpawnArgs = options => {
76
const {
@@ -14,16 +13,28 @@ const makeSpawnArgs = options => {
1413
cmd,
1514
args,
1615
stdioString,
16+
nodeGyp,
1717
} = options
1818

19+
if (nodeGyp) {
20+
// npm already pulled this from env and passes it in to options
21+
npm_config_node_gyp = nodeGyp
22+
} else if (env.npm_config_node_gyp) {
23+
// legacy mode for standalone user
24+
npm_config_node_gyp = env.npm_config_node_gyp
25+
} else {
26+
// default
27+
npm_config_node_gyp = require.resolve('node-gyp/bin/node-gyp.js')
28+
}
29+
1930
const spawnEnv = setPATH(path, binPaths, {
2031
// we need to at least save the PATH environment var
2132
...process.env,
2233
npm_package_json: resolve(path, 'package.json'),
2334
npm_lifecycle_event: event,
2435
npm_lifecycle_script: cmd,
25-
npm_config_node_gyp,
2636
...env,
37+
npm_config_node_gyp,
2738
})
2839

2940
const spawnOpts = {

0 commit comments

Comments
 (0)