Skip to content

Commit

Permalink
Re-add yargs/yargs#783 workaround for parserConfiguration
Browse files Browse the repository at this point in the history
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 <kevin@kevinlocke.name>
  • Loading branch information
kevinoid committed Feb 18, 2019
1 parent 45815b4 commit 3ad382c
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion bin/cmd.js
Expand Up @@ -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,
Expand Down

0 comments on commit 3ad382c

Please sign in to comment.