Permalink
Browse files

make `node-gyp -v` and `node-gyp --version` work as expected

  • Loading branch information...
1 parent de20581 commit 6d8d7b1d3292faa661dfc809e34695691b92fd3a @TooTallNate TooTallNate committed Jul 31, 2012
Showing with 10 additions and 7 deletions.
  1. +6 −1 bin/node-gyp.js
  2. +4 −6 lib/node-gyp.js
View
@@ -22,7 +22,12 @@ var completed = false
prog.parseArgv(process.argv)
if (prog.todo.length === 0) {
- return prog.usageAndExit()
+ if (~process.argv.indexOf('-v') || ~process.argv.indexOf('--version')) {
+ console.log('v%s', prog.version)
+ } else {
+ console.log('%s', prog.usage())
+ }
+ return process.exit(0)
}
log.info('it worked if it ends with', 'ok')
View
@@ -174,10 +174,10 @@ proto.spawn = function spawn (command, args, opts) {
}
/**
- * Prints the usage instructions and then exits.
+ * Returns the usage instructions for node-gyp.
*/
-proto.usageAndExit = function usageAndExit () {
+proto.usage = function usage () {
var usage = [
''
, ' Usage: node-gyp <command> [options]'
@@ -193,13 +193,11 @@ proto.usageAndExit = function usageAndExit () {
, 'node-gyp@' + this.version + ' ' + path.resolve(__dirname, '..')
, 'node@' + process.versions.node
].join('\n')
-
- console.log(usage)
- process.exit(4)
+ return usage
}
/**
- * Version number proxy.
+ * Version number getter.
*/
Object.defineProperty(proto, 'version', {

0 comments on commit 6d8d7b1

Please sign in to comment.