Skip to content

Commit

Permalink
feat: bump yargs to 17 (#5165)
Browse files Browse the repository at this point in the history
* feat: bump yargs to 17

* fix: prefer coerced reporter-option for options

* Aha, fix: process.exit() instead of process.exitCode

* fix: --list-interfaces one-and-done conflict
  • Loading branch information
JoshuaKGoldberg authored Jan 2, 2025
1 parent 6caa902 commit 8f1c8d8
Show file tree
Hide file tree
Showing 6 changed files with 181 additions and 177 deletions.
6 changes: 3 additions & 3 deletions lib/cli/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

const debug = require('debug')('mocha:cli:cli');
const symbols = require('log-symbols');
const yargs = require('yargs/yargs');
const yargs = require('yargs');
const path = require('path');
const {
loadRc,
Expand Down Expand Up @@ -63,15 +63,15 @@ exports.main = (argv = process.argv.slice(2), mochaArgs) => {
debug('caught error sometime before command handler: %O', err);
yargs.showHelp();
console.error(`\n${symbols.error} ${ansi.red('ERROR:')} ${msg}`);
process.exitCode = 1;
process.exit(1);
})
.help('help', 'Show usage information & exit')
.alias('help', 'h')
.version('version', 'Show version number & exit', version)
.alias('version', 'V')
.wrap(process.stdout.columns ? Math.min(process.stdout.columns, 80) : 80)
.epilog(
`Mocha Resources
`${ansi.reset("Mocha Resources")}
Chat: ${ansi.magenta(discord)}
GitHub: ${ansi.blue(repository.url)}
Docs: ${ansi.yellow(homepage)}
Expand Down
4 changes: 2 additions & 2 deletions lib/cli/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,11 +169,11 @@ exports.builder = yargs =>
group: GROUPS.RULES
},
'list-interfaces': {
conflicts: Array.from(ONE_AND_DONE_ARGS),
conflicts: Array.from(ONE_AND_DONE_ARGS).filter(arg => arg !== "list-interfaces"),
description: 'List built-in user interfaces & exit'
},
'list-reporters': {
conflicts: Array.from(ONE_AND_DONE_ARGS),
conflicts: Array.from(ONE_AND_DONE_ARGS).filter(arg => arg !== "list-reporters"),
description: 'List built-in reporters & exit'
},
'no-colors': {
Expand Down
4 changes: 3 additions & 1 deletion lib/mocha.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,9 @@ function Mocha(options = {}) {
.ui(options.ui)
.reporter(
options.reporter,
options.reporterOption || options.reporterOptions // for backwards compatibility
options['reporter-option'] ||
options.reporterOption ||
options.reporterOptions // for backwards compatibility
)
.slow(options.slow)
.global(options.global);
Expand Down
Loading

0 comments on commit 8f1c8d8

Please sign in to comment.