From 8fcbf34be56729063891b6bb2436ba2ae1936bc0 Mon Sep 17 00:00:00 2001 From: Thomas Scholtes Date: Wed, 26 Jun 2019 12:32:13 +0200 Subject: [PATCH] fixup! Deconstruct and normalize CLI options in one place --- lib/cli/collect-files.js | 8 ++++++++ lib/cli/run-helpers.js | 2 +- lib/cli/watch-run.js | 6 +++--- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/lib/cli/collect-files.js b/lib/cli/collect-files.js index ad4699ec6e..ff35ed3d36 100644 --- a/lib/cli/collect-files.js +++ b/lib/cli/collect-files.js @@ -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 diff --git a/lib/cli/run-helpers.js b/lib/cli/run-helpers.js index bac3fbc377..fce5e6250c 100644 --- a/lib/cli/run-helpers.js +++ b/lib/cli/run-helpers.js @@ -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 diff --git a/lib/cli/watch-run.js b/lib/cli/watch-run.js index a2264c812c..10d4407673 100644 --- a/lib/cli/watch-run.js +++ b/lib/cli/watch-run.js @@ -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); @@ -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(); };