Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorisaacs <i@izs.me>2012-06-15 20:27:41 +0400
committerisaacs <i@izs.me>2012-06-15 20:27:41 +0400
commit7fa19049310eed9d766f10fb6e6edd9101676515 (patch)
tree6a9de4b69d411135f8195230fcaa38251b47b477 /node_modules/node-gyp/lib/node-gyp.js
parent8689ba87305fb49025f73f9fc4a10dbce070f22d (diff)
Update node-gyp to 0.5
Diffstat (limited to 'node_modules/node-gyp/lib/node-gyp.js')
-rw-r--r--node_modules/node-gyp/lib/node-gyp.js64
1 files changed, 29 insertions, 35 deletions
diff --git a/node_modules/node-gyp/lib/node-gyp.js b/node_modules/node-gyp/lib/node-gyp.js
index ad92e817a..85374e41e 100644
--- a/node_modules/node-gyp/lib/node-gyp.js
+++ b/node_modules/node-gyp/lib/node-gyp.js
@@ -8,6 +8,7 @@ module.exports = exports = gyp
var fs = require('graceful-fs')
, path = require('path')
, nopt = require('nopt')
+ , log = require('npmlog')
, child_process = require('child_process')
, EE = require('events').EventEmitter
, inherits = require('util').inherits
@@ -27,6 +28,8 @@ var fs = require('graceful-fs')
, 'rm': 'remove'
}
+log.heading = 'gyp'
+
/**
* The `gyp` function.
*/
@@ -36,10 +39,10 @@ function gyp () {
}
function Gyp () {
- var me = this
+ var self = this
// set the dir where node-gyp dev files get installed
- // TODO: make this configurable?
+ // TODO: make this *more* configurable?
// see: https://github.com/TooTallNate/node-gyp/issues/21
var homeDir = process.env.HOME || process.env.USERPROFILE
this.devDir = path.resolve(homeDir, '.node-gyp')
@@ -47,15 +50,11 @@ function Gyp () {
this.commands = {}
commands.forEach(function (command) {
- me.commands[command] = function (argv, callback) {
- me.verbose('command', command, argv)
- return require('./' + command)(me, argv, callback)
+ self.commands[command] = function (argv, callback) {
+ log.verbose('command', command, argv)
+ return require('./' + command)(self, argv, callback)
}
})
-
- Object.keys(aliases).forEach(function (alias) {
- me.commands[alias] = me.commands[aliases[alias]]
- })
}
inherits(Gyp, EE)
exports.Gyp = Gyp
@@ -78,10 +77,10 @@ proto.configDefs = {
, directory: String // bin
, msvs_version: String // 'configure'
, ensure: Boolean // 'install'
- , verbose: Boolean // everywhere
, solution: String // 'build' (windows only)
, proxy: String // 'install'
, nodedir: String // 'configure'
+ , loglevel: String // everywhere
}
/**
@@ -91,10 +90,18 @@ proto.configDefs = {
proto.shorthands = {
release: '--no-debug'
, C: '--directory'
- , d: '--debug'
+ , debug: '--debug'
+ , silly: '--loglevel=silly'
+ , verbose: '--loglevel=verbose'
}
/**
+ * expose the command aliases for the bin file to use.
+ */
+
+proto.aliases = aliases
+
+/**
* Parses the given argv array and sets the 'opts',
* 'argv' and 'command' properties.
*/
@@ -105,7 +112,7 @@ proto.parseArgv = function parseOpts (argv) {
var commands = []
this.argv.slice().forEach(function (arg) {
- if (arg in this.commands) {
+ if (arg in this.commands || arg in this.aliases) {
this.argv.splice(this.argv.indexOf(arg), 1)
commands.push(arg)
}
@@ -119,10 +126,7 @@ proto.parseArgv = function parseOpts (argv) {
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
- }
+ log.level = val
} else {
// take the config name and check if it's one that node-gyp cares about
name = name.substring(npm_config_prefix.length)
@@ -131,6 +135,11 @@ proto.parseArgv = function parseOpts (argv) {
}
}
}, this)
+
+ if (this.opts.loglevel) {
+ log.level = this.opts.loglevel
+ }
+ log.resume()
}
/**
@@ -143,31 +152,15 @@ proto.spawn = function spawn (command, args, opts) {
opts.customFds = [ 0, 1, 2 ]
}
var cp = child_process.spawn(command, args, opts)
- this.emit('spawn', command, args, cp)
+ log.info('spawn', command)
+ log.info('spawn args', args)
return cp
}
/**
- * Logging mechanisms.
+ * Prints the usage instructions and then exits.
*/
-proto.info = function info () {
- var args = Array.prototype.slice.call(arguments)
- args.unshift('info')
- this.emit.apply(this, args)
-}
-proto.warn = function warn () {
- var args = Array.prototype.slice.call(arguments)
- args.unshift('warn')
- this.emit.apply(this, args)
-}
-
-proto.verbose = function verbose () {
- var args = Array.prototype.slice.call(arguments)
- args.unshift('verbose')
- this.emit.apply(this, args)
-}
-
proto.usageAndExit = function usageAndExit () {
var usage = [
''
@@ -182,6 +175,7 @@ proto.usageAndExit = function usageAndExit () {
, ' $ node-gyp <command> --help'
, ''
, 'node-gyp@' + this.version + ' ' + path.resolve(__dirname, '..')
+ , 'node@' + process.versions.node
].join('\n')
console.log(usage)