UNPKG

712 BJavaScriptView Raw
1'use strict'
2
3const test = require('tap').test
4const gyp = require('../lib/node-gyp')
5
6test('options in environment', function (t) {
7 t.plan(1)
8
9 // `npm test` dumps a ton of npm_config_* variables in the environment.
10 Object.keys(process.env)
11 .filter(function (key) { return /^npm_config_/.test(key) })
12 .forEach(function (key) { delete process.env[key] })
13
14 // Zero-length keys should get filtered out.
15 process.env.npm_config_ = '42'
16 // Other keys should get added.
17 process.env.npm_config_x = '42'
18 // Except loglevel.
19 process.env.npm_config_loglevel = 'debug'
20
21 var g = gyp()
22 g.parseArgv(['rebuild']) // Also sets opts.argv.
23
24 t.deepEqual(Object.keys(g.opts).sort(), ['argv', 'x'])
25})