Strage bug (in upstream node core?)
Node:
v8.4.0
When I run the following code (bug.js):
#!/usr/bin/env node
const program = require('commander');
program
.version('0.0.1')
.option('-n --name [name]', 'Specify name of this vhost')
.option('-p --port [port]', 'Specify port')
.option('-r --protocol [protocol]', 'Specify protocol (http or https)')
.option('-t --target [target]', 'Specify the target endpoint')
.option('-d --domain [domain]', 'Specify the domain name')
program.parse(process.argv);
with the following command:
node bug.js -n test -r https -p 8080 -d "sdsd" -t "12312"
I get this:
events.js:198
domain.enter();
^
TypeError: domain.enter is not a function
at Command.emit (events.js:198:12)
at Command.parseOptions (/home/tomasz/dev/hardbox-cli/node_modules/commander/index.js:719:14)
at Command.parse (/home/tomasz/dev/hardbox-cli/node_modules/commander/index.js:454:21)
at Object.<anonymous> (/home/tomasz/dev/hardbox-cli/bug.js:13:10)
at Module._compile (module.js:573:30)
at Object.Module._extensions..js (module.js:584:10)
at Module.load (module.js:507:32)
at tryModuleLoad (module.js:470:12)
at Function.Module._load (module.js:462:3)
at Function.Module.runMain (module.js:609:10)
It seems to only happen when i use '--domain'. Anything else I tried works fine (ex: '--domain1')
It does look like an upstream bug, but I want to double check.
Unfortunately, currently commander doesn't support properties/methods of Node.js' EventEmitter, plus those which it defines itself as an option/command. It's known issue and is misimplementation from the early ages of commander.
This would be something to keep an eye on when building 3.0. Such a hugely popular module should be rock solid.
Duplication of #284, which is similar to #681, #105. Closed. Keep your eyes on #105 issue, thx