summaryrefslogtreecommitdiff
path: root/deps/npm/node_modules/node-gyp/lib/node-gyp.js
diff options
context:
space:
mode:
authorisaacs <i@izs.me>2012-03-14 16:39:15 -0700
committerisaacs <i@izs.me>2012-03-14 16:44:36 -0700
commitf631c1d73b83d8c10b4121fb060f5817db6811d3 (patch)
tree2f881e2a7fd9204bf58a9388d526060556fff2e3 /deps/npm/node_modules/node-gyp/lib/node-gyp.js
parentad5a108dfd5bb0a0b46c0f328adda28fa4edcd8e (diff)
downloadnode-f631c1d73b83d8c10b4121fb060f5817db6811d3.tar.gz
Update npm to 1.1.9
Diffstat (limited to 'deps/npm/node_modules/node-gyp/lib/node-gyp.js')
-rw-r--r--deps/npm/node_modules/node-gyp/lib/node-gyp.js140
1 files changed, 140 insertions, 0 deletions
diff --git a/deps/npm/node_modules/node-gyp/lib/node-gyp.js b/deps/npm/node_modules/node-gyp/lib/node-gyp.js
new file mode 100644
index 000000000..efa53435e
--- /dev/null
+++ b/deps/npm/node_modules/node-gyp/lib/node-gyp.js
@@ -0,0 +1,140 @@
+
+module.exports = exports = gyp
+
+/**
+ * Module dependencies.
+ */
+
+var fs = require('fs')
+ , path = require('path')
+ , nopt = require('nopt')
+ , child_process = require('child_process')
+ , EE = require('events').EventEmitter
+ , inherits = require('util').inherits
+ , commands = [
+ // Module build commands
+ 'build'
+ , 'clean'
+ , 'configure'
+ , 'rebuild'
+ // Development Header File management commands
+ , 'install'
+ , 'list'
+ , 'remove'
+ ]
+ , aliases = {
+ 'ls': 'list'
+ , 'rm': 'remove'
+ }
+
+/**
+ * The `gyp` function.
+ */
+
+function gyp () {
+ return new Gyp
+}
+
+function Gyp () {
+ var me = this
+
+ this.commands = {}
+ commands.forEach(function (command) {
+ me.commands[command] = function (argv, callback) {
+ me.verbose('command', command, argv)
+ return require('./' + command)(me, argv, callback)
+ }
+ })
+}
+inherits(Gyp, EE)
+exports.Gyp = Gyp
+var proto = Gyp.prototype
+
+/**
+ * Export the contents of the package.json.
+ */
+
+proto.package = require('../package')
+
+proto.configDefs = {
+ help: Boolean // everywhere
+ , arch: String // 'configure'
+ , msvs_version: String // 'configure'
+ , debug: Boolean // 'build'
+ , ensure: Boolean // 'install'
+ , verbose: Boolean // everywhere
+ , solution: String // 'build' (windows only)
+ , proxy: String // 'install'
+}
+
+proto.shorthands = {}
+
+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
+}
+
+/**
+ * Spawns a child process and emits a 'spawn' event.
+ */
+
+proto.spawn = function spawn (command, args, opts) {
+ opts || (opts = {})
+ if (!opts.silent && !opts.customFds) {
+ opts.customFds = [ 0, 1, 2 ]
+ }
+ var cp = child_process.spawn(command, args, opts)
+ this.emit('spawn', command, args, cp)
+ return cp
+}
+
+/**
+ * Logging mechanisms.
+ */
+
+proto.info = function info () {
+ var args = Array.prototype.slice.call(arguments)
+ args.unshift('info')
+ 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 = [
+ ''
+ , ' Usage: node-gyp <command> [options]'
+ , ''
+ , ' where <command> is one of:'
+ , commands.map(function (c) {
+ return ' - ' + c + ' - ' + require('./' + c).usage
+ }).join('\n')
+ , ''
+ , ' for specific command usage and options try:'
+ , ' $ node-gyp <command> --help'
+ , ''
+ , 'node-gyp@' + this.version + ' ' + path.resolve(__dirname, '..')
+ ].join('\n')
+
+ console.log(usage)
+ process.exit(4)
+}
+
+/**
+ * Version number proxy.
+ */
+
+Object.defineProperty(proto, 'version', {
+ get: function () {
+ return this.package.version
+ }
+ , enumerable: true
+})
+