finki-main
main
|
Last change
on this file since 81bc7da was 81bc7da, checked in by Klimentina Efremova <klimentina08642@…>, 3 months ago |
|
Initial commit
|
-
Property mode
set to
100644
|
|
File size:
923 bytes
|
| Line | |
|---|
| 1 | 'use strict'
|
|---|
| 2 |
|
|---|
| 3 | const test = require('tap').test
|
|---|
| 4 | const gyp = require('../lib/node-gyp')
|
|---|
| 5 |
|
|---|
| 6 | test('options in environment', (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((key) => /^npm_config_/.test(key))
|
|---|
| 12 | .forEach((key) => { delete process.env[key] })
|
|---|
| 13 |
|
|---|
| 14 | // in some platforms, certain keys are stubborn and cannot be removed
|
|---|
| 15 | const keys = Object.keys(process.env)
|
|---|
| 16 | .filter((key) => /^npm_config_/.test(key))
|
|---|
| 17 | .map((key) => key.substring('npm_config_'.length))
|
|---|
| 18 | .concat('argv', 'x')
|
|---|
| 19 |
|
|---|
| 20 | // Zero-length keys should get filtered out.
|
|---|
| 21 | process.env.npm_config_ = '42'
|
|---|
| 22 | // Other keys should get added.
|
|---|
| 23 | process.env.npm_config_x = '42'
|
|---|
| 24 | // Except loglevel.
|
|---|
| 25 | process.env.npm_config_loglevel = 'debug'
|
|---|
| 26 |
|
|---|
| 27 | const g = gyp()
|
|---|
| 28 | g.parseArgv(['rebuild']) // Also sets opts.argv.
|
|---|
| 29 |
|
|---|
| 30 | t.deepEqual(Object.keys(g.opts).sort(), keys.sort())
|
|---|
| 31 | })
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.