Skip to content

Commit 7ed640f

Browse files
committed
feat: support formatOptions. resolves #29.
1 parent 367fb19 commit 7ed640f

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

src/reporters/basic.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@ import { writeStream } from '../utils/stream'
44
import { formatDate } from '../utils/date'
55

66
const DEFAULTS = {
7-
dateFormat: 'HH:mm:ss'
7+
dateFormat: 'HH:mm:ss',
8+
formatOptions: {
9+
colors: false,
10+
compact: true
11+
}
812
}
913

1014
const bracket = x => x ? `[${x}]` : ''
@@ -26,8 +30,10 @@ export default class BasicReporter {
2630
return arg
2731
})
2832

33+
// Only supportet with Node >= 10
34+
// https://nodejs.org/api/util.html#util_util_inspect_object_options
2935
if (typeof util.formatWithOptions === 'function') {
30-
return util.formatWithOptions({ colors: true }, ..._args) // Node >= 10
36+
return util.formatWithOptions(this.options.formatOptions, ..._args)
3137
} else {
3238
return util.format(..._args)
3339
}

src/reporters/fancy.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@ import { chalkColor, chalkBgColor } from '../utils/chalk'
66
import { TYPE_COLOR_MAP, LEVEL_COLOR_MAP } from '../utils/fancy'
77

88
const DEFAULTS = {
9-
secondaryColor: 'grey'
9+
secondaryColor: 'grey',
10+
formatOptions: {
11+
colors: true,
12+
compact: false
13+
}
1014
}
1115

1216
const TYPE_ICONS = {

0 commit comments

Comments
 (0)