diff --git a/index.js b/index.js index 7d3e94b1c..1abf4df9d 100644 --- a/index.js +++ b/index.js @@ -288,8 +288,8 @@ Command.prototype.action = function(fn) { fn.apply(self, args); }; - this.parent.on('action_' + this._name, listener); - if (this._alias) this.parent.on('action_' + this._alias, listener); + this.parent.on(this._name, listener); + if (this._alias) this.parent.on(this._alias, listener); return this; }; @@ -568,8 +568,8 @@ Command.prototype.parseArgs = function(args, unknown) { if (args.length) { name = args[0]; - if (this.listeners('action_' + name).length) { - this.emit('action_' + args.shift(), args, unknown); + if (this.listeners(name).length) { + this.emit(args.shift(), args, unknown); } else { this.emit('*', args); } diff --git a/test/test.options.same-name-arg.js b/test/test.options.same-name-arg.js deleted file mode 100644 index 4ce05a1b4..000000000 --- a/test/test.options.same-name-arg.js +++ /dev/null @@ -1,14 +0,0 @@ -/** - * Module dependencies. - */ - -var program = require('../') - , should = require('should'); - -program - .version('0.0.1') - .option('--string ', 'pass a string') - -program.parse('node test string --string myString'.split(' ')); -program.string.should.equal('myString'); -program.args.should.containEql('string');