Skip to content

Commit

Permalink
added support for inheriting config env variable from npm
Browse files Browse the repository at this point in the history
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
TooTallNate committed May 27, 2012
1 parent b064c70 commit 470f04e
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions lib/node-gyp.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

/**
Expand Down

0 comments on commit 470f04e

Please sign in to comment.