Permalink
Browse files

support subcommands on windows. Fixes #142

  • Loading branch information...
1 parent 38b7adb commit 892d8c33d67f11d3d9436fdb3c9a4e1c802265ce @yiminghe yiminghe committed Sep 30, 2013
Showing with 4 additions and 3 deletions.
  1. +4 −3 index.js
View
@@ -361,7 +361,7 @@ Command.prototype.parse = function(argv){
this.rawArgs = argv;
// guess name
- this._name = this._name || basename(argv[1]);
+ this._name = this._name || basename(argv[1], '.js');
// process argv
var parsed = this.parseOptions(this.normalize(argv.slice(2)));
@@ -399,14 +399,15 @@ Command.prototype.executeSubCommand = function(argv, args, unknown) {
// executable
var dir = dirname(argv[1]);
- var bin = basename(argv[1]) + '-' + args[0];
+ var bin = basename(argv[1], '.js') + '-' + args[0];
// check for ./<bin> first
var local = path.join(dir, bin);
// run it
args = args.slice(1);
- var proc = spawn(local, args, { stdio: 'inherit', customFds: [0, 1, 2] });
+ args.unshift(local);
+ var proc = spawn('node', args, { stdio: 'inherit', customFds: [0, 1, 2] });
proc.on('error', function(err){
if (err.code == "ENOENT") {
console.error('\n %s(1) does not exist, try --help\n', bin);

0 comments on commit 892d8c3

Please sign in to comment.