Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

added support for inheriting config env variable from npm

So you can pass node-gyp-specific flags to npm, and node-gyp will
automatically use them:

  $ npm install weak --nodedir=`pwd` --prefix=`pwd`

Part of #70.
  • Loading branch information...
commit 470f04efebbd05fee38b85202d1a830c90382c45 1 parent b064c70
@TooTallNate TooTallNate authored
Showing with 19 additions and 0 deletions.
  1. +19 −0 lib/node-gyp.js
View
19 lib/node-gyp.js
@@ -112,6 +112,25 @@ proto.parseArgv = function parseOpts (argv) {
}, this)
this.todo = commands
+
+ // support for inheriting config env variables from npm
+ var npm_config_prefix = 'npm_config_'
+ Object.keys(process.env).forEach(function (name) {
+ if (name.indexOf(npm_config_prefix) !== 0) return
+ var val = process.env[name]
+ if (name === npm_config_prefix + 'loglevel') {
+ // "loglevel" is a special case; check for "verbose"
+ if (val === 'verbose') {
+ this.opts.verbose = true
+ }
+ } else {
+ // take the config name and check if it's one that node-gyp cares about
+ name = name.substring(npm_config_prefix.length)
+ if (name in this.configDefs) {
+ this.opts[name] = val
+ }
+ }
+ }, this)
}
/**

0 comments on commit 470f04e

Please sign in to comment.
Something went wrong with that request. Please try again.