Skip to content

Commit

Permalink
update yargs; closes #3742
Browse files Browse the repository at this point in the history
  • Loading branch information
boneskull committed Mar 6, 2019
1 parent b27bc60 commit d2e28a3
Show file tree
Hide file tree
Showing 4 changed files with 186 additions and 110 deletions.
3 changes: 2 additions & 1 deletion lib/cli/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const debug = require('debug')('mocha:cli:cli');
const symbols = require('log-symbols');
const yargs = require('yargs');
const path = require('path');
const {loadOptions} = require('./options');
const {loadOptions, YARGS_PARSER_CONFIG} = require('./options');
const commands = require('./commands');
const ansi = require('ansi-colors');
const {repository, homepage, version, gitter} = require('../../package.json');
Expand Down Expand Up @@ -59,6 +59,7 @@ exports.main = (argv = process.argv.slice(2)) => {
Docs: ${ansi.yellow(homepage)}
`
)
.parserConfiguration(YARGS_PARSER_CONFIG)
.parse(argv, loadOptions(argv));
};

Expand Down
14 changes: 12 additions & 2 deletions lib/cli/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ const yargsParser = require('yargs-parser');
const {types, aliases} = require('./run-option-metadata');
const {ONE_AND_DONE_ARGS} = require('./one-and-dones');
const mocharc = require('../mocharc.json');
const yargsParserConfig = require('../../package.json').yargs;
const {list} = require('./run-helpers');
const {loadConfig, findConfig} = require('./config');
const findup = require('findup-sync');
Expand All @@ -32,6 +31,16 @@ const {isNodeFlag} = require('./node-flags');
* @interface Arguments
*/

/**
* Base yargs parser configuration
* @private
*/
const YARGS_PARSER_CONFIG = {
'combine-arrays': true,
'short-option-groups': false,
'dot-notation': false
};

/**
* This is the config pulled from the `yargs` property of Mocha's
* `package.json`, but it also disables camel case expansion as to
Expand All @@ -40,7 +49,7 @@ const {isNodeFlag} = require('./node-flags');
* @private
* @ignore
*/
const configuration = Object.assign({}, yargsParserConfig, {
const configuration = Object.assign({}, YARGS_PARSER_CONFIG, {
'camel-case-expansion': false
});

Expand Down Expand Up @@ -335,3 +344,4 @@ const loadOptions = (argv = []) => {
};

module.exports.loadOptions = loadOptions;
module.exports.YARGS_PARSER_CONFIG = YARGS_PARSER_CONFIG;
Loading

0 comments on commit d2e28a3

Please sign in to comment.