Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
feat(fancy): highlight keywords with grave accent char
  • Loading branch information
pooya parsa committed Feb 23, 2019
1 parent 34738c7 commit b3e09fd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
2 changes: 2 additions & 0 deletions examples/special.js
Expand Up @@ -18,6 +18,8 @@ consola.error({ type: 'CSSError', message: 'Use scss' })

consola.error(undefined, null, false, true, NaN)

consola.log('We can `monospace` keyword using grave accent charachter!')

// Nonstandard error
const { message, stack } = new Error('Custom Error!')
consola.error({ message, stack })
3 changes: 3 additions & 0 deletions src/reporters/fancy.js
@@ -1,5 +1,6 @@
import stringWidth from 'string-width'
import figures from 'figures'
import chalk from 'chalk'
import BasicReporter from './basic'
import { parseStack } from '../utils/error'
import { chalkColor, chalkBgColor } from '../utils/chalk'
Expand Down Expand Up @@ -77,6 +78,8 @@ export default class FancyReporter extends BasicReporter {

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

line = line.replace(/`(.+)`/g, (_, m) => chalk.cyan(m))

return isBadge ? '\n' + line + '\n' : line
}
}

0 comments on commit b3e09fd

Please sign in to comment.