diff --git a/package.json b/package.json index a1dcb037e..7871b7097 100644 --- a/package.json +++ b/package.json @@ -47,7 +47,7 @@ "preinstall": "node ./bootstrap-hoist", "serve-coverage": "python3 -m http.server -d output/lcov-report 8080", "test": "mocha --reporter ./reporter packages/*/lib/tests/test-*.js", - "test-coverage": "c8 -o output -r lcov -r text mocha --reporter ./reporter packages/*/lib/tests/test-*.js | tee output/summary.txt" + "test-coverage": "c8 -o output -r lcov -r text mocha --no-color --reporter ./reporter packages/*/lib/tests/test-*.js | tee output/summary.txt" }, "version": "0.0.0" } diff --git a/reporter.js b/reporter.js index ad3f6506d..3ef676eef 100644 --- a/reporter.js +++ b/reporter.js @@ -14,7 +14,10 @@ const { // See: https://stackoverflow.com/questions/9781218/how-to-change-node-jss-console-font-color -const disableColor = !(process.stdout.isTTY); +let disableColor = false; //!(process.stdout.isTTY); +process.argv.forEach((arg) => { + if (arg === "--no-color") { disableColor = true; } +}); const Colors = { "blue": "\x1b[0;34m", @@ -36,8 +39,9 @@ const Colors = { }; function colorify(text) { - if (disableColor) { return text; } return unescapeColor(text.replace(/(<([a-z+]+)>)/g, (all, _, color) => { + if (disableColor) { return ""; } + const seq = Colors[color]; if (seq == null) { console.log("UNKNOWN COLOR:", color);