There is a regression in the version v1.17
See this sample:
var program = require("commander");
program
.version("0.0.1")
.command("*")
.description("test")
.action(function(cmd) {
cmdValue = cmd;
});
program.parse(process.argv);
if (typeof cmdValue === "undefined") {
console.error("no command given!");
} else {
console.log("command:", cmdValue);
}
v1.16
$ node test.js
no command given!
v1.17
$ node test.js
command: Command {
commands: [],
options: [],
_execs: {},
_allowUnknownOption: false,
_args: [],
_name: '*',
_noHelp: false,
parent:
Command {
commands: [ [Circular] ],
options: [ [Object] ],
_execs: {},
_allowUnknownOption: false,
_args: [],
_name: 'test',
Command: { [Function: Command] super_: [Object] },
Option: [Function: Option],
_version: '0.0.1',
_versionOptionName: 'version',
_events:
{ 'option:version': [Function],
'command:*': [Function: listener] },
_eventsCount: 2,
rawArgs:
[ 'C:\\Program Files\\nodejs\\node.exe',
'C:\\Users\\schroeterm\\Desktop\\test\\test.js' ],
args: [] },
_description: 'test',
_argsDescription: undefined }
There is a regression in the version v1.17
See this sample:
v1.16
v1.17
$ node test.js command: Command { commands: [], options: [], _execs: {}, _allowUnknownOption: false, _args: [], _name: '*', _noHelp: false, parent: Command { commands: [ [Circular] ], options: [ [Object] ], _execs: {}, _allowUnknownOption: false, _args: [], _name: 'test', Command: { [Function: Command] super_: [Object] }, Option: [Function: Option], _version: '0.0.1', _versionOptionName: 'version', _events: { 'option:version': [Function], 'command:*': [Function: listener] }, _eventsCount: 2, rawArgs: [ 'C:\\Program Files\\nodejs\\node.exe', 'C:\\Users\\schroeterm\\Desktop\\test\\test.js' ], args: [] }, _description: 'test', _argsDescription: undefined }