From ca86673604a88cfddc1fee060c0a6151edc2cf2c Mon Sep 17 00:00:00 2001 From: abetomo Date: Tue, 7 Aug 2018 16:57:37 +0900 Subject: [PATCH 1/2] Fix a bug in command emit fixes: #843 fixes: #842 --- index.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index eebaec03a..3ad0cacfd 100644 --- a/index.js +++ b/index.js @@ -660,7 +660,8 @@ Command.prototype.parseArgs = function(args, unknown) { if (unknown.length > 0) { this.unknownOption(unknown[0]); } - if (this._args.filter(a => a.required).length === 0) { + if (this.commands.length === 0 && + this._args.filter(function(a) { return a.required }).length === 0) { this.emit('command:*'); } } From a682fc90a9aab22aef69fb094c896a778dc684ed Mon Sep 17 00:00:00 2001 From: abetomo Date: Tue, 7 Aug 2018 16:59:29 +0900 Subject: [PATCH 2/2] Add test case --- test/test.commandAsterisk.action.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 test/test.commandAsterisk.action.js diff --git a/test/test.commandAsterisk.action.js b/test/test.commandAsterisk.action.js new file mode 100644 index 000000000..d72381054 --- /dev/null +++ b/test/test.commandAsterisk.action.js @@ -0,0 +1,15 @@ +var program = require('../') + , should = require('should'); + +var val = false; +program + .version('0.0.1') + .command('*') + .description('test') + .action(function () { + val = true; + }); + +program.parse(['node', 'test']); + +val.should.be.false()