diff --git a/lib/cli/cli.js b/lib/cli/cli.js index 5a4c6b8d53..e6486f0efc 100755 --- a/lib/cli/cli.js +++ b/lib/cli/cli.js @@ -22,7 +22,7 @@ const { } = require('./options'); const lookupFiles = require('./lookup-files'); const commands = require('./commands'); -const ansi = require('ansi-colors'); +const {blue, magenta, red, yellow} = require('ansis'); const {repository, homepage, version, discord} = require('../../package.json'); const {cwd} = require('../utils'); @@ -62,7 +62,7 @@ exports.main = (argv = process.argv.slice(2), mochaArgs) => { .fail((msg, err, yargs) => { debug('caught error sometime before command handler: %O', err); yargs.showHelp(); - console.error(`\n${symbols.error} ${ansi.red('ERROR:')} ${msg}`); + console.error(`\n${symbols.error} ${red`ERROR:`} ${msg}`); process.exitCode = 1; }) .help('help', 'Show usage information & exit') @@ -72,9 +72,9 @@ exports.main = (argv = process.argv.slice(2), mochaArgs) => { .wrap(process.stdout.columns ? Math.min(process.stdout.columns, 80) : 80) .epilog( `Mocha Resources - Chat: ${ansi.magenta(discord)} - GitHub: ${ansi.blue(repository.url)} - Docs: ${ansi.yellow(homepage)} + Chat: ${magenta(discord)} + GitHub: ${blue(repository.url)} + Docs: ${yellow(homepage)} ` ) .parserConfiguration(YARGS_PARSER_CONFIG) diff --git a/lib/cli/collect-files.js b/lib/cli/collect-files.js index 73f5d2e95a..17066502e7 100644 --- a/lib/cli/collect-files.js +++ b/lib/cli/collect-files.js @@ -2,7 +2,7 @@ const fs = require('fs'); const path = require('path'); -const ansi = require('ansi-colors'); +const {red, yellow} = require('ansis'); const debug = require('debug')('mocha:cli:run:helpers'); const minimatch = require('minimatch'); const {NO_FILES_MATCH_PATTERN} = require('../errors').constants; @@ -94,12 +94,12 @@ module.exports = ({ unmatchedSpecFiles[0].pattern )}` // stringify to print escaped characters raw : 'Error: No test files found'; - console.error(ansi.red(noneFoundMsg)); + console.error(red(noneFoundMsg)); process.exit(1); } else { // print messages as a warning unmatchedSpecFiles.forEach(warning => { - console.warn(ansi.yellow(`Warning: ${warning.message}`)); + console.warn(yellow`Warning: ${warning.message}`); }); } diff --git a/lib/cli/options.js b/lib/cli/options.js index 09351957b4..444bb5bf7c 100644 --- a/lib/cli/options.js +++ b/lib/cli/options.js @@ -8,7 +8,7 @@ */ const fs = require('fs'); -const ansi = require('ansi-colors'); +const {red} = require('ansis'); const yargsParser = require('yargs-parser'); const { types, @@ -180,7 +180,7 @@ const parse = (args = [], defaultValues = {}, ...configObjects) => { boolean: types.boolean.concat(nodeArgs.map(pair => pair[0])) }); if (result.error) { - console.error(ansi.red(`Error: ${result.error.message}`)); + console.error(red`Error: ${result.error.message}`); process.exit(1); } diff --git a/lib/cli/run-helpers.js b/lib/cli/run-helpers.js index ec65829f14..5767d19171 100644 --- a/lib/cli/run-helpers.js +++ b/lib/cli/run-helpers.js @@ -9,7 +9,7 @@ const fs = require('fs'); const path = require('path'); -const ansi = require('ansi-colors'); +const {yellow} = require('ansis'); const debug = require('debug')('mocha:cli:run:helpers'); const {watchRun, watchParallelRun} = require('./watch-run'); const collectFiles = require('./collect-files'); @@ -121,9 +121,7 @@ const handleUnmatchedFiles = (mocha, unmatchedFiles) => { unmatchedFiles.forEach(({pattern, absolutePath}) => { console.error( - ansi.yellow( - `Warning: Cannot find any files matching pattern "${pattern}" at the absolute path "${absolutePath}"` - ) + yellow`Warning: Cannot find any files matching pattern "${pattern}" at the absolute path "${absolutePath}"` ); }); console.log( diff --git a/lib/cli/run.js b/lib/cli/run.js index 206e3305d0..8b6792ab42 100644 --- a/lib/cli/run.js +++ b/lib/cli/run.js @@ -8,7 +8,7 @@ */ const symbols = require('log-symbols'); -const ansi = require('ansi-colors'); +const {red} = require('ansis'); const Mocha = require('../mocha'); const { createUnsupportedError, @@ -357,7 +357,7 @@ exports.builder = yargs => Object.assign(argv, plugins); } catch (err) { // this could be a bad --require, bad reporter, ui, etc. - console.error(`\n${symbols.error} ${ansi.red('ERROR:')}`, err); + console.error(`\n${symbols.error} ${red`ERROR:`}`, err); yargs.exit(1); } }) diff --git a/package-lock.json b/package-lock.json index 77bcf5c1a2..aaa8209da0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,7 @@ "version": "11.0.2", "license": "MIT", "dependencies": { - "ansi-colors": "^4.1.3", + "ansis": "3.4.0", "browser-stdout": "^1.3.1", "chokidar": "^3.5.3", "debug": "^4.3.5", @@ -2265,14 +2265,6 @@ "ajv": "^6.9.1" } }, - "node_modules/ansi-colors": { - "version": "4.1.3", - "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.3.tgz", - "integrity": "sha512-/6w/C21Pm1A7aZitlI5Ni/2J6FFQN8i1Cvz3kHABAAbw93v/NlvKdVOqz7CCWz/3iv/JplRSEEZ83XION15ovw==", - "engines": { - "node": ">=6" - } - }, "node_modules/ansi-red": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/ansi-red/-/ansi-red-0.1.1.tgz", @@ -2316,6 +2308,15 @@ "node": ">=0.10.0" } }, + "node_modules/ansis": { + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/ansis/-/ansis-3.4.0.tgz", + "integrity": "sha512-zVESKSQhWaPhGaWiKj1k+UqvpC7vPBBgG3hjQEeIx2YGzylWt8qA3ziAzRuUtm0OnaGsZKjIvfl8D/sJTt/I0w==", + "license": "ISC", + "engines": { + "node": ">=16" + } + }, "node_modules/anymatch": { "version": "3.1.3", "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.3.tgz", @@ -17896,11 +17897,6 @@ "dev": true, "requires": {} }, - "ansi-colors": { - "version": "4.1.3", - "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.3.tgz", - "integrity": "sha512-/6w/C21Pm1A7aZitlI5Ni/2J6FFQN8i1Cvz3kHABAAbw93v/NlvKdVOqz7CCWz/3iv/JplRSEEZ83XION15ovw==" - }, "ansi-red": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/ansi-red/-/ansi-red-0.1.1.tgz", @@ -17929,6 +17925,11 @@ "integrity": "sha512-ZyznvL8k/FZeQHr2T6LzcJ/+vBApDnMNZvfVFy3At0knswWd6rJ3/0Hhmpu8oqa6C92npmozs890sX9Dl6q+Qw==", "dev": true }, + "ansis": { + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/ansis/-/ansis-3.4.0.tgz", + "integrity": "sha512-zVESKSQhWaPhGaWiKj1k+UqvpC7vPBBgG3hjQEeIx2YGzylWt8qA3ziAzRuUtm0OnaGsZKjIvfl8D/sJTt/I0w==" + }, "anymatch": { "version": "3.1.3", "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.3.tgz", diff --git a/package.json b/package.json index fad58e1555..139983fa16 100644 --- a/package.json +++ b/package.json @@ -94,7 +94,7 @@ "version": "run-p version:* && git add -A ./AUTHORS ./CHANGELOG.md" }, "dependencies": { - "ansi-colors": "^4.1.3", + "ansis": "3.4.0", "browser-stdout": "^1.3.1", "chokidar": "^3.5.3", "debug": "^4.3.5",