mirror of
https://github.com/electron/node-gyp.git
synced 2025-08-15 12:58:19 +02:00
fix: _ in npm_config_ env variables
This commit is contained in:
parent
a32a9aa8e6
commit
eef4eefccb
3 changed files with 17 additions and 1 deletions
|
@ -19,7 +19,8 @@ async function getBaseConfigGypi ({ gyp, nodeDir }) {
|
|||
// try reading $nodeDir/include/node/config.gypi first when:
|
||||
// 1. --dist-url or --nodedir is specified
|
||||
// 2. and --force-process-config is not specified
|
||||
const shouldReadConfigGypi = (gyp.opts.nodedir || gyp.opts['dist-url']) && !gyp.opts['force-process-config']
|
||||
const useCustomHeaders = gyp.opts.nodedir || gyp.opts.disturl || gyp.opts['dist-url']
|
||||
const shouldReadConfigGypi = useCustomHeaders && !gyp.opts['force-process-config']
|
||||
if (shouldReadConfigGypi && nodeDir) {
|
||||
try {
|
||||
const baseConfigGypiPath = path.resolve(nodeDir, 'include/node/config.gypi')
|
||||
|
|
|
@ -149,6 +149,10 @@ proto.parseArgv = function parseOpts (argv) {
|
|||
// gyp@741b7f1 enters an infinite loop when it encounters
|
||||
// zero-length options so ensure those don't get through.
|
||||
if (name) {
|
||||
// convert names like force_process_config to force-process-config
|
||||
if (name.includes('_')) {
|
||||
name = name.replace(/_/g, '-')
|
||||
}
|
||||
this.opts[name] = val
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,3 +29,14 @@ test('options in environment', (t) => {
|
|||
|
||||
t.deepEqual(Object.keys(g.opts).sort(), keys.sort())
|
||||
})
|
||||
|
||||
test('options with spaces in environment', (t) => {
|
||||
t.plan(1)
|
||||
|
||||
process.env.npm_config_force_process_config = 'true'
|
||||
|
||||
const g = gyp()
|
||||
g.parseArgv(['rebuild']) // Also sets opts.argv.
|
||||
|
||||
t.equal(g.opts['force-process-config'], 'true')
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue