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

Command name "inspect" causes weird behaviour #377

Closed
feyzo opened this issue Mar 19, 2015 · 3 comments
Closed

Command name "inspect" causes weird behaviour #377

feyzo opened this issue Mar 19, 2015 · 3 comments
Labels
bug Commander is not working as intended

Comments

@feyzo
Copy link

feyzo commented Mar 19, 2015

How to reproduce

  1. Put the code below in index.js, install commander, run node index.js
  2. Result: error: missing required argument 'some'
  3. Change command inspect to someothercommand
  4. Result: Actual log of the commander object
var program = require('commander');

program
  .command('inspect <some>')
  .description('Test bug')
  .action(function(some, options) {});

console.log(program);
@SomeKittens SomeKittens added the bug Commander is not working as intended label Mar 19, 2015
@moul
Copy link

moul commented Mar 27, 2015

👍 same issue here

> require('commander').command('close').action(console.log).parse(['close'])
{ commands: [],
  options: [],
  _execs: [],
  _allowUnknownOption: false,
  _args: [],
  _name: 'close',
  parent:
   { commands:
      [ [Object],
        [Object],
        [Object],
        [Object],
        [Circular] ],
     options: [],
     _execs: [],
     _allowUnknownOption: false,
     _args: [],
     _name: undefined,
     Command: [Function: Command],
     Option: [Function: Option],
     _events: { close: [Object] } },
  rawArgs: [ 'close' ],
  args: [] }
> require('commander').command('inspect').action(console.log).parse(['inspect'])

console.js:52
Console.prototype.log = function() {
                                ^
RangeError: Maximum call stack size exceeded

It seems to be related to the EventEmitter system with reserved keywords.
Maybe we can prefix commands on .on(command)

@iainjreid
Copy link

I'm a little late to the party, but I'm experiencing this error too. Does anybody have any workarounds aside from simply changing the command name?

@shadowspawn
Copy link
Collaborator

Closing this as covered by #183 and #933

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

No branches or pull requests

5 participants