Skip to content

Commit

Permalink
fixup! Deconstruct and normalize CLI options in one place
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Scholtes committed Jun 26, 2019
1 parent b8d2d42 commit 8fcbf34
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
8 changes: 8 additions & 0 deletions lib/cli/collect-files.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@ const debug = require('debug')('mocha:cli:run:helpers');
const minimatch = require('minimatch');
const utils = require('../utils');

/**
* Exports a function that collects test files from CLI parameters.
* @see module:lib/cli/run-helpers
* @see module:lib/cli/watch-run
* @module
* @private
*/

/**
* Smash together an array of test files in the correct order
* @param {Object} opts - Options
Expand Down
2 changes: 1 addition & 1 deletion lib/cli/run-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ exports.handleRequires = (requires = []) => {
};

/**
* Give Mocha files and tell it to run
* Collect test files and run mocha instance.
* @param {Mocha} mocha - Mocha instance
* @param {Options} [opts] - Command line options
* @param {boolean} [opts.exit] - Whether or not to force-exit after tests are complete
Expand Down
6 changes: 3 additions & 3 deletions lib/cli/watch-run.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const collectFiles = require('./collect-files');
* @param {string[]} fileCollectParams.extension - List of extensions to watch
* @private
*/
module.exports = (mocha, options, fileCollectParams) => {
module.exports = (mocha, {grep, ui}, fileCollectParams) => {
let runner;
const files = collectFiles(fileCollectParams);

Expand Down Expand Up @@ -64,12 +64,12 @@ module.exports = (mocha, options, fileCollectParams) => {
const rerun = () => {
purge();
eraseLine();
if (!options.grep) {
if (!grep) {
mocha.grep(null);
}
mocha.suite = mocha.suite.clone();
mocha.suite.ctx = new Context();
mocha.ui(options.ui);
mocha.ui(ui);
loadAndRun();
};

Expand Down

0 comments on commit 8fcbf34

Please sign in to comment.