forked from tj/commander.js
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
resolves tj#560 respect custom name for version option
- Loading branch information
1 parent
e5d8f04
commit 89e06ad
Showing
3 changed files
with
44 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
var program = require('../') | ||
, should = require('should'); | ||
|
||
var capturedExitCode, capturedOutput, oldProcessExit, oldProcessStdoutWrite; | ||
|
||
program.version('0.0.1', '-r, --revision'); | ||
|
||
['-r', '--revision'].forEach(function (flag) { | ||
capturedExitCode = -1; | ||
capturedOutput = ''; | ||
oldProcessExit = process.exit; | ||
oldProcessStdoutWrite = process.stdout.write; | ||
process.exit = function (code) { capturedExitCode = code; } | ||
process.stdout.write = function(output) { capturedOutput += output; } | ||
program.parse(['node', 'test', flag]); | ||
process.exit = oldProcessExit; | ||
process.stdout.write = oldProcessStdoutWrite; | ||
capturedOutput.should.equal('0.0.1\n'); | ||
capturedExitCode.should.equal(0); | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
var program = require('../') | ||
, should = require('should'); | ||
|
||
var capturedExitCode, capturedOutput, oldProcessExit, oldProcessStdoutWrite; | ||
|
||
program.version('0.0.1'); | ||
|
||
['-V', '--version'].forEach(function (flag) { | ||
capturedExitCode = -1; | ||
capturedOutput = ''; | ||
oldProcessExit = process.exit; | ||
oldProcessStdoutWrite = process.stdout.write; | ||
process.exit = function (code) { capturedExitCode = code; } | ||
process.stdout.write = function(output) { capturedOutput += output; } | ||
program.parse(['node', 'test', flag]); | ||
process.exit = oldProcessExit; | ||
process.stdout.write = oldProcessStdoutWrite; | ||
capturedOutput.should.equal('0.0.1\n'); | ||
capturedExitCode.should.equal(0); | ||
}) |