Skip to content

Commit b3e09fd

Browse files
author
pooya parsa
committedFeb 23, 2019
feat(fancy): highlight keywords with grave accent char
1 parent 34738c7 commit b3e09fd

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed
 

‎examples/special.js

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ consola.error({ type: 'CSSError', message: 'Use scss' })
1818

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

21+
consola.log('We can `monospace` keyword using grave accent charachter!')
22+
2123
// Nonstandard error
2224
const { message, stack } = new Error('Custom Error!')
2325
consola.error({ message, stack })

‎src/reporters/fancy.js

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import stringWidth from 'string-width'
22
import figures from 'figures'
3+
import chalk from 'chalk'
34
import BasicReporter from './basic'
45
import { parseStack } from '../utils/error'
56
import { chalkColor, chalkBgColor } from '../utils/chalk'
@@ -77,6 +78,8 @@ export default class FancyReporter extends BasicReporter {
7778

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

81+
line = line.replace(/`(.+)`/g, (_, m) => chalk.cyan(m))
82+
8083
return isBadge ? '\n' + line + '\n' : line
8184
}
8285
}

0 commit comments

Comments
 (0)
Please sign in to comment.