forked from tj/commander.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request tj#502 from bkendall/fix-sub-sub-commands
Fix Sub-Subcommands
- Loading branch information
Showing
6 changed files
with
43 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
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 @@ | ||
console.log('cache-clear') |
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 @@ | ||
console.log('cache-validate') |
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,6 @@ | ||
var program = require('../../'); | ||
|
||
program | ||
.command('clear', 'clear the cache') | ||
.command('validate', 'validate the cache', { isDefault: true }) | ||
.parse(process.argv); |
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,32 @@ | ||
var exec = require('child_process').exec | ||
, path = require('path') | ||
, should = require('should'); | ||
|
||
|
||
/* | ||
* The commands look like this | ||
* pm cache | ||
* pm cache clear | ||
* pm cache validate (default) | ||
*/ | ||
|
||
var bin = path.join(__dirname, './fixtures/pm') | ||
// should list commands at top-level sub command | ||
exec(bin + ' cache help', function (error, stdout, stderr) { | ||
stdout.should.containEql('Usage:'); | ||
stdout.should.containEql('cache'); | ||
stdout.should.containEql('validate'); | ||
}); | ||
|
||
// should run sub-subcommand | ||
exec(bin + ' cache clear', function (error, stdout, stderr) { | ||
stdout.should.equal('cache-clear\n'); | ||
stderr.should.equal(''); | ||
}); | ||
|
||
// should print the default command when passed invalid sub-subcommand | ||
exec(bin + ' cache nope', function (error, stdout, stderr) { | ||
stdout.should.equal('cache-validate\n'); | ||
stderr.should.equal(''); | ||
}); | ||
|