Skip to content

Commit

Permalink
feat: smart hide time and tag when there is no space
Browse files Browse the repository at this point in the history
  • Loading branch information
pooya parsa committed May 25, 2019
1 parent d8b1c98 commit 00a375f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/reporters/basic.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export default class BasicReporter {

log (logObj, { async, stdout, stderr } = {}) {
const line = this.formatLogObj(logObj, {
width: stdout.columns ? (stdout.columns - 1) : 80
width: stdout.columns ? (stdout.columns - 1) : 0
})

return writeStream(
Expand Down
12 changes: 6 additions & 6 deletions src/reporters/fancy.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,14 @@ export default class FancyReporter extends BasicReporter {
const tag = logObj.tag ? secondaryColor(logObj.tag) : ''

let line
let left = this.filterAndJoin([type, message])
let right = this.filterAndJoin([tag, date])
const left = this.filterAndJoin([type, message])
const right = this.filterAndJoin([tag, date])
const space = width - stringWidth(left) - stringWidth(right) - 2

if (width > 80) {
const space = width - stringWidth(left) - stringWidth(right) - 2
line = space > 0 ? (left + ' '.repeat(space) + right) : left
if (space > 0) {
line = left + ' '.repeat(space) + right
} else {
line = right + ' ' + left
line = left
}

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

0 comments on commit 00a375f

Please sign in to comment.