diff options
Diffstat (limited to 'node_modules/node-gyp/lib/node-gyp.js')
-rw-r--r-- | node_modules/node-gyp/lib/node-gyp.js | 48 |
1 files changed, 44 insertions, 4 deletions
diff --git a/node_modules/node-gyp/lib/node-gyp.js b/node_modules/node-gyp/lib/node-gyp.js index efa53435e..1b014e6cd 100644 --- a/node_modules/node-gyp/lib/node-gyp.js +++ b/node_modules/node-gyp/lib/node-gyp.js @@ -5,7 +5,7 @@ module.exports = exports = gyp * Module dependencies. */ -var fs = require('fs') +var fs = require('graceful-fs') , path = require('path') , nopt = require('nopt') , child_process = require('child_process') @@ -38,13 +38,24 @@ function gyp () { function Gyp () { var me = this + // set the dir where node-gyp dev files get installed + // TODO: make this 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') + this.commands = {} + commands.forEach(function (command) { me.commands[command] = function (argv, callback) { me.verbose('command', command, argv) return require('./' + command)(me, argv, callback) } }) + + Object.keys(aliases).forEach(function (alias) { + me.commands[alias] = me.commands[aliases[alias]] + }) } inherits(Gyp, EE) exports.Gyp = Gyp @@ -56,9 +67,14 @@ var proto = Gyp.prototype proto.package = require('../package') +/** + * nopt configuration definitions + */ + proto.configDefs = { help: Boolean // everywhere , arch: String // 'configure' + , directory: String // bin , msvs_version: String // 'configure' , debug: Boolean // 'build' , ensure: Boolean // 'install' @@ -67,14 +83,33 @@ proto.configDefs = { , proxy: String // 'install' } -proto.shorthands = {} +/** + * nopt shorthands + */ + +proto.shorthands = { + release: '--no-debug' + , C: '--directory' +} + +/** + * Parses the given argv array and sets the 'opts', + * 'argv' and 'command' properties. + */ proto.parseArgv = function parseOpts (argv) { this.opts = nopt(this.configDefs, this.shorthands, argv) this.argv = this.opts.argv.remain.slice() - var command = this.argv.shift() - this.command = aliases[command] || command + var commands = [] + this.argv.slice().forEach(function (arg) { + if (arg in this.commands) { + this.argv.splice(this.argv.indexOf(arg), 1) + commands.push(arg) + } + }, this) + + this.todo = commands } /** @@ -100,6 +135,11 @@ proto.info = function info () { 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) |