Skip to content

Commit 8fcbf34

Browse files
author
Thomas Scholtes
committed
fixup! Deconstruct and normalize CLI options in one place
1 parent b8d2d42 commit 8fcbf34

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

lib/cli/collect-files.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@ const debug = require('debug')('mocha:cli:run:helpers');
66
const minimatch = require('minimatch');
77
const utils = require('../utils');
88

9+
/**
10+
* Exports a function that collects test files from CLI parameters.
11+
* @see module:lib/cli/run-helpers
12+
* @see module:lib/cli/watch-run
13+
* @module
14+
* @private
15+
*/
16+
917
/**
1018
* Smash together an array of test files in the correct order
1119
* @param {Object} opts - Options

lib/cli/run-helpers.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ exports.handleRequires = (requires = []) => {
9292
};
9393

9494
/**
95-
* Give Mocha files and tell it to run
95+
* Collect test files and run mocha instance.
9696
* @param {Mocha} mocha - Mocha instance
9797
* @param {Options} [opts] - Command line options
9898
* @param {boolean} [opts.exit] - Whether or not to force-exit after tests are complete

lib/cli/watch-run.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const collectFiles = require('./collect-files');
2323
* @param {string[]} fileCollectParams.extension - List of extensions to watch
2424
* @private
2525
*/
26-
module.exports = (mocha, options, fileCollectParams) => {
26+
module.exports = (mocha, {grep, ui}, fileCollectParams) => {
2727
let runner;
2828
const files = collectFiles(fileCollectParams);
2929

@@ -64,12 +64,12 @@ module.exports = (mocha, options, fileCollectParams) => {
6464
const rerun = () => {
6565
purge();
6666
eraseLine();
67-
if (!options.grep) {
67+
if (!grep) {
6868
mocha.grep(null);
6969
}
7070
mocha.suite = mocha.suite.clone();
7171
mocha.suite.ctx = new Context();
72-
mocha.ui(options.ui);
72+
mocha.ui(ui);
7373
loadAndRun();
7474
};
7575

0 commit comments

Comments
 (0)