Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
don't seperate additional part
  • Loading branch information
pi0 committed Nov 2, 2018
1 parent 38600fe commit 5c694af
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 18 deletions.
19 changes: 5 additions & 14 deletions src/reporters/basic.js
Expand Up @@ -26,18 +26,10 @@ export default class BasicReporter {
return arg
})

let formattedArgs
if (util.formatWithOptions) {
formattedArgs = util.formatWithOptions({ colors: true }, ..._args) // Node >= 10
if (typeof util.formatWithOptions === 'function') {
return util.formatWithOptions({ colors: true }, ..._args) // Node >= 10
} else {
formattedArgs = util.format(..._args)
}

const [ message, ...more ] = formattedArgs.split('\n')

return {
message,
additional: more.join('\n')
return util.format(..._args)
}
}

Expand All @@ -50,7 +42,7 @@ export default class BasicReporter {
}

formatLogObj (logObj) {
const { message, additional } = this.formatArgs(logObj.args)
const message = this.formatArgs(logObj.args)

const date = this.formatDate(logObj.date)
const type = logObj.type.toUpperCase()
Expand All @@ -59,8 +51,7 @@ export default class BasicReporter {
bracket(date),
bracket(logObj.tag),
bracket(type),
message,
additional ? ('\n' + additional) : ''
message
])
}

Expand Down
12 changes: 8 additions & 4 deletions src/reporters/fancy.js
Expand Up @@ -26,7 +26,11 @@ export default class FancyReporter extends BasicReporter {
}

formatStack (stack) {
return ' at ' + parseStack(stack).join(' ↲\n at ')
return ' at ' + parseStack(stack)
.map(line => {
return line
})
.join(' ↲\n at ')
}

typeColor (type, level) {
Expand All @@ -47,7 +51,7 @@ export default class FancyReporter extends BasicReporter {
}

formatLogObj (logObj, { width }) {
const { message, additional } = this.formatArgs(logObj.args)
const [ message, ...additional ] = this.formatArgs(logObj.args).split('\n')

const isBadge = logObj.badge || logObj.level < 2

Expand All @@ -66,8 +70,8 @@ export default class FancyReporter extends BasicReporter {

let line = space > 0 ? (left + ' '.repeat(space) + right) : left

line += additional
? secondaryColor('\n' + additional)
line += additional.length
? '\n' + additional.join('\n')
: ''

return isBadge ? '\n' + line + '\n' : line
Expand Down

0 comments on commit 5c694af

Please sign in to comment.