From d67c9391b5a797ddb2adf8a212d29b51ae6e5a24 Mon Sep 17 00:00:00 2001 From: Marvin Hagemeister Date: Sat, 4 Jul 2020 17:24:05 +0200 Subject: [PATCH] Shorten console output if in watch mode (#44) * Shorten log output if in watch mode * Fix pretty log format for min reporter Co-authored-by: Jason Miller --- package.json | 1 + src/configure.js | 2 +- src/lib/patch.js | 8 +++++++- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 2628487..0707c13 100644 --- a/package.json +++ b/package.json @@ -35,6 +35,7 @@ "eslint": "^7.3.0", "eslint-config-developit": "^1.2.0", "eslint-config-prettier": "^6.11.0", + "karma-min-reporter": "^0.1.0", "microbundle": "^0.12.2", "prettier": "^1.19.1", "webpack": "^4.43.0", diff --git a/src/configure.js b/src/configure.js index ea7b0a9..ee3b683 100644 --- a/src/configure.js +++ b/src/configure.js @@ -204,7 +204,7 @@ export default function configure(options) { basePath: cwd, plugins: PLUGINS.map((req) => require.resolve(req)), frameworks: ['jasmine'], - reporters: ['spec'].concat( + reporters: [options.watch ? 'min' : 'spec'].concat( options.coverage ? 'coverage' : [], useSauceLabs ? 'saucelabs' : [] ), diff --git a/src/lib/patch.js b/src/lib/patch.js index f8aa049..bda5992 100644 --- a/src/lib/patch.js +++ b/src/lib/patch.js @@ -3,7 +3,13 @@ import chalk from 'chalk'; let { write } = process.stdout; process.stdout.write = (msg) => { // Strip + prettify console forwarded output: - let matches = msg.match(/^LOG ([A-Z]+): ([\s\S]*)$/); + let matches = msg.match(/^LOG\s*([A-Z]+): ([\s\S]*)$/); + + // "min" reporter has slightly different output + if (!matches) { + matches = msg.match(/^(LOG): ([\s\S]*)$/); + } + if (matches) { msg = chalk.bgBlueBright.white(' ' + matches[1] + ': ') +