From 3ad382cc53e4a705987fbbcdb2ad78b8801e690d Mon Sep 17 00:00:00 2001 From: Kevin Locke Date: Mon, 18 Feb 2019 15:57:48 -0700 Subject: [PATCH] Re-add yargs/yargs#783 workaround for parserConfiguration Unfortunately yargs configuration in package.json takes precedence over .parserConfiguration(), so under mocha (which has yargs in its package.json) the .parserConfiguration() call is ignored. Re-add the require.main workaround to prevent this. Signed-off-by: Kevin Locke --- bin/cmd.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/bin/cmd.js b/bin/cmd.js index 14ca6f1..8d191fb 100755 --- a/bin/cmd.js +++ b/bin/cmd.js @@ -120,7 +120,10 @@ function modulenameCmd(args, options, callback) { return undefined; } - const yargs = new Yargs() + // Workaround for https://github.com/yargs/yargs/issues/783 + // Necessary because mocha package.json overrides .parserConfiguration() + require.main = module; + const yargs = new Yargs(null, null, require) .parserConfiguration({ 'parse-numbers': false, 'duplicate-arguments-array': false,