Skip to content

Regression between v1.16 and v1.17 when no command are passed and '*' is registered #843

@Skywalker13

Description

@Skywalker13

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 }

Metadata

Metadata

Assignees

Labels

bugCommander is not working as intended

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions