Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
Skywalker13 opened this issue Aug 7, 2018 · 1 comment · Fixed by #844
Closed
Assignees
Labels
bug Commander is not working as intended

Comments

@Skywalker13
Copy link

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 }
@abetomo
Copy link
Collaborator

abetomo commented Aug 7, 2018

Thanks for the report!
It is a bug when I fixed this issue (#778).
I will fix it.

@abetomo abetomo self-assigned this Aug 7, 2018
@abetomo abetomo added the bug Commander is not working as intended label Aug 7, 2018
Skywalker13 added a commit to Xcraft-Inc/shellcraft.js that referenced this issue Aug 7, 2018
Use commander@1.16 because of bug in 1.17.
See tj/commander.js#843
abetomo added a commit to abetomo/commander.js that referenced this issue Aug 7, 2018
roman-vanesyan pushed a commit that referenced this issue Aug 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Commander is not working as intended
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants