Skip to content
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion lib/make-spawn-args.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/* eslint camelcase: "off" */
const setPATH = require('./set-path.js')
const { resolve } = require('path')
const npm_config_node_gyp = require.resolve('node-gyp/bin/node-gyp.js')

const makeSpawnArgs = options => {
const {
Expand All @@ -14,8 +13,20 @@ const makeSpawnArgs = options => {
cmd,
args,
stdioString,
nodeGyp,
} = options

if (nodeGyp) {
// npm already pulled this from env and passes it in to options
npm_config_node_gyp = nodeGyp
} else if (env.npm_config_node_gyp) {
// legacy mode for standalone user
npm_config_node_gyp = env.npm_config_node_gyp
} else {
// default
npm_config_node_gyp = require.resolve('node-gyp/bin/node-gyp.js')
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even if we built a safeguard in here in case require.resolve wasn't available we'd still need this to throw if this default was needed and failed, so it's effectively a NOP. If you need this code to work in an environment that doesn't have require.resolve you can pass in the option or set the environment variable.

}

const spawnEnv = setPATH(path, binPaths, {
// we need to at least save the PATH environment var
...process.env,
Expand Down
Loading