Skip to content

Commit

Permalink
Bump yargs (#227)
Browse files Browse the repository at this point in the history
  • Loading branch information
1999 committed Apr 17, 2019
1 parent c7d2b27 commit da7659f
Show file tree
Hide file tree
Showing 14 changed files with 223 additions and 80 deletions.
248 changes: 192 additions & 56 deletions package-lock.json

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
],
"dependencies": {
"circular-json": "^0.5.9",
"debug": "4.1.1",
"yargs": "12.0.1"
"debug": "^4.1.1",
"yargs": "^13.2.2"
},
"repository": {
"type": "git",
Expand Down Expand Up @@ -68,7 +68,7 @@
"@types/debug": "^4.1.4",
"@types/mocha": "^5.2.1",
"@types/node": "^10.1.3",
"@types/yargs": "^11.0.0",
"@types/yargs": "^13.0.0",
"babel-plugin-transform-react-jsx": "^6.24.1",
"babel-register": "^6.26.0",
"chai": "^4.2.0",
Expand Down
17 changes: 10 additions & 7 deletions src/bin/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,16 +97,19 @@ const argv = yargs
alias: 't',
number: true,
})
.option('timeouts', {
boolean: true,
})
.parse(process.argv);

// --async-only
applyAsyncOnly(mocha, argv.asyncOnly);
applyAsyncOnly(mocha, argv['async-only']);

// --bail
applyBail(mocha, argv.bail);

// --check-leaks
applyCheckLeaks(mocha, argv.checkLeaks);
applyCheckLeaks(mocha, argv['check-leaks']);

// --compilers
const { compilers, extensions } = applyCompilers(argv.compilers);
Expand All @@ -125,13 +128,13 @@ applyForbidOnly(mocha, argv.forbidOnly);
applyForbidPending(mocha, argv.forbidPending);

// --full-trace
applyFullTrace(mocha, argv.fullTrace);
applyFullTrace(mocha, argv['full-trace']);

// --grep option
applyGrepPattern(mocha, argv.grep);

// --max-parallel
applyMaxParallel(mocha, argv.maxParallel);
applyMaxParallel(mocha, argv['max-parallel']);

// --no-timeouts
applyNoTimeouts(mocha, argv.timeouts);
Expand All @@ -141,8 +144,8 @@ const requires = applyRequires(argv.require);
mocha.addRequiresForSubprocess(requires);

// --reporter-options
const reporterOptions = argv.reporterOptions !== undefined
? applyReporterOptions(argv.reporterOptions)
const reporterOptions = argv['reporter-options'] !== undefined
? applyReporterOptions(argv['reporter-options'])
: {};

// --reporter
Expand All @@ -158,7 +161,7 @@ applySlow(mocha, argv.slow);
applyTimeout(mocha, argv.timeout);

// find files
const files = getFilesList(argv._.slice(2), extensions, argv.recursive);
const files = getFilesList(argv._.slice(2), extensions, argv.recursive || false);

if (!files.length) {
// tslint:disable-next-line:no-console
Expand Down
2 changes: 1 addition & 1 deletion src/bin/options/async-only.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as Mocha from 'mocha';

export default function applyAsyncOnly(mocha: Mocha, asyncOnly: boolean) {
export default function applyAsyncOnly(mocha: Mocha, asyncOnly?: boolean) {
if (asyncOnly) {
mocha.asyncOnly();
}
Expand Down
4 changes: 2 additions & 2 deletions src/bin/options/bail.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as Mocha from 'mocha';

export default function applyBail(mocha: Mocha, bail: boolean) {
mocha.suite.bail(bail);
export default function applyBail(mocha: Mocha, bail?: boolean) {
mocha.suite.bail(bail || false);
}
2 changes: 1 addition & 1 deletion src/bin/options/check-leaks.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as Mocha from 'mocha';

export default function applyCheckLeaks(mocha: Mocha, checkLeaks: boolean) {
export default function applyCheckLeaks(mocha: Mocha, checkLeaks?: boolean) {
if (checkLeaks) {
mocha.checkLeaks();
}
Expand Down
2 changes: 1 addition & 1 deletion src/bin/options/exit.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Mocha from '../../main/mocha';

export default function applyExit(mocha: Mocha, exitMode: boolean) {
export default function applyExit(mocha: Mocha, exitMode?: boolean) {
if (exitMode) {
mocha.enableExitMode();
}
Expand Down
2 changes: 1 addition & 1 deletion src/bin/options/forbid-only.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as Mocha from 'mocha';

export default function applyForbidOnly(mocha: Mocha, forbidOnly: boolean) {
export default function applyForbidOnly(mocha: Mocha, forbidOnly?: boolean) {
if (forbidOnly) {
mocha.forbidOnly();
}
Expand Down
2 changes: 1 addition & 1 deletion src/bin/options/forbid-pending.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as Mocha from 'mocha';

export default function applyForbidPending(mocha: Mocha, forbidPending: boolean) {
export default function applyForbidPending(mocha: Mocha, forbidPending?: boolean) {
if (forbidPending) {
mocha.forbidPending();
}
Expand Down
2 changes: 1 addition & 1 deletion src/bin/options/full-trace.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as Mocha from 'mocha';

export default function applyFullTrace(mocha: Mocha, fullTrace: boolean) {
export default function applyFullTrace(mocha: Mocha, fullTrace?: boolean) {
if (fullTrace) {
mocha.fullTrace();
}
Expand Down
2 changes: 1 addition & 1 deletion src/bin/options/retries.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as Mocha from 'mocha';

export default function applyRetries(mocha: Mocha, retries: number) {
export default function applyRetries(mocha: Mocha, retries?: number) {
if (retries) {
mocha.suite.retries(retries);
}
Expand Down
2 changes: 1 addition & 1 deletion src/bin/options/slow.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as Mocha from 'mocha';

export default function applySlow(mocha: Mocha, slow: number) {
export default function applySlow(mocha: Mocha, slow?: number) {
if (slow) {
mocha.suite.slow(slow);
}
Expand Down
6 changes: 5 additions & 1 deletion src/subprocess/runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ const argv = yargs
boolean: true,
})
.number('slow')
.option('test', {
demandOption: true,
string: true,
})
.option('require', {
array: true,
default: [],
Expand Down Expand Up @@ -256,7 +260,7 @@ applyRequires(argv.require);
applyTimeouts(mocha, argv.timeout);

// --full-trace
applyFullTrace(mocha, argv.fullTrace);
applyFullTrace(mocha, argv['full-trace']);

// apply main process root suite properties
for (const option of SUITE_OWN_OPTIONS) {
Expand Down
6 changes: 3 additions & 3 deletions src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export function applyCompilers(compilers: any): ICLICompilers {
return output;
}

export function applyDelay(mocha: Mocha, delay: boolean) {
export function applyDelay(mocha: Mocha, delay?: boolean) {
if (delay) {
mocha.delay();
}
Expand All @@ -74,13 +74,13 @@ export function applyGrepPattern(mocha: Mocha, stringPattern?: string) {
}
}

export function applyNoTimeouts(mocha: Mocha, allowTimeouts: boolean) {
export function applyNoTimeouts(mocha: Mocha, allowTimeouts?: boolean) {
if (allowTimeouts === false) {
mocha.enableTimeouts(false);
}
}

export function applyTimeouts(mocha: Mocha, timeout: number) {
export function applyTimeouts(mocha: Mocha, timeout?: number) {
if (timeout) {
mocha.suite.timeout(timeout);
}
Expand Down

0 comments on commit da7659f

Please sign in to comment.