Skip to content

Commit

Permalink
feat: support formatOptions. resolves #29.
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Nov 4, 2018
1 parent 367fb19 commit 7ed640f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
10 changes: 8 additions & 2 deletions src/reporters/basic.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ import { writeStream } from '../utils/stream'
import { formatDate } from '../utils/date'

const DEFAULTS = {
dateFormat: 'HH:mm:ss'
dateFormat: 'HH:mm:ss',
formatOptions: {
colors: false,
compact: true
}
}

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

// Only supportet with Node >= 10
// https://nodejs.org/api/util.html#util_util_inspect_object_options
if (typeof util.formatWithOptions === 'function') {
return util.formatWithOptions({ colors: true }, ..._args) // Node >= 10
return util.formatWithOptions(this.options.formatOptions, ..._args)
} else {
return util.format(..._args)
}
Expand Down
6 changes: 5 additions & 1 deletion src/reporters/fancy.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ import { chalkColor, chalkBgColor } from '../utils/chalk'
import { TYPE_COLOR_MAP, LEVEL_COLOR_MAP } from '../utils/fancy'

const DEFAULTS = {
secondaryColor: 'grey'
secondaryColor: 'grey',
formatOptions: {
colors: true,
compact: false
}
}

const TYPE_ICONS = {
Expand Down

1 comment on commit 7ed640f

@gkatsanos
Copy link

@gkatsanos gkatsanos commented on 7ed640f Jan 31, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pi0 I passed consola.setReporters([ new consola.FancyReporter({ compact: false }) ]) and I still see

  data: {
    content: [
      [Object],
      [Object],
      [Object],
      [Object],
      [Object],
      [Object],
      [Object],
      [Object]
    ],
in the 3+ levels of nesting. Am I doing something wrong there? 

Please sign in to comment.