From bd8be0002315b23bfdb44d4459d832c4e6bd23c1 Mon Sep 17 00:00:00 2001 From: Rifad Ainun Nazieb Date: Wed, 14 Aug 2019 21:04:56 +0700 Subject: [PATCH] fix showing help for sub commands with custom executableFile --- index.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/index.js b/index.js index f69b1597d..e812b61d3 100644 --- a/index.js +++ b/index.js @@ -458,6 +458,14 @@ Command.prototype.parse = function(argv) { var result = this.parseArgs(this.args, parsed.unknown); + if (args[0] === 'help' && args.length === 1) this.help(); + + // --help + if (args[0] === 'help') { + args[0] = args[1]; + args[1] = this._helpLongFlag; + } + // executable sub-commands // (Debugging note for future: args[0] is not right if an action has been called) var name = result.args[0]; @@ -511,13 +519,6 @@ Command.prototype.executeSubCommand = function(argv, args, unknown, executableFi args = args.concat(unknown); if (!args.length) this.help(); - if (args[0] === 'help' && args.length === 1) this.help(); - - // --help - if (args[0] === 'help') { - args[0] = args[1]; - args[1] = this._helpLongFlag; - } var isExplicitJS = false; // Whether to use node to launch "executable"