Skip to content

Commit

Permalink
Shorten console output if in watch mode (#44)
Browse files Browse the repository at this point in the history
* Shorten log output if in watch mode

* Fix pretty log format for min reporter

Co-authored-by: Jason Miller <developit@users.noreply.github.com>
  • Loading branch information
marvinhagemeister and developit authored Jul 4, 2020
1 parent d5cc345 commit d67c939
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion src/configure.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' : []
),
Expand Down
8 changes: 7 additions & 1 deletion src/lib/patch.js
Original file line number Diff line number Diff line change
Expand Up @@ -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] + ': ') +
Expand Down

0 comments on commit d67c939

Please sign in to comment.