test-options.js 713 B

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