From b3e09fd92be292e3f6e52a1f41b8d9e396e99dc1 Mon Sep 17 00:00:00 2001 From: pooya parsa Date: Sat, 23 Feb 2019 21:45:21 +0330 Subject: [PATCH] feat(fancy): highlight keywords with grave accent char --- examples/special.js | 2 ++ src/reporters/fancy.js | 3 +++ 2 files changed, 5 insertions(+) diff --git a/examples/special.js b/examples/special.js index 74a9442..88fa972 100755 --- a/examples/special.js +++ b/examples/special.js @@ -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 }) diff --git a/src/reporters/fancy.js b/src/reporters/fancy.js index 4af8fe7..9202aee 100644 --- a/src/reporters/fancy.js +++ b/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' @@ -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 } }