Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function logType(type: LogType, message: string, other?: any): void {
const icon: any = iconMapping[type];
const prefix: any = (prefixMapping as any)[type];
const colorLog = colorLogger(type);
/* eslint-disable no-console */
console.log(
`${icon ? colorLog(fig(icon)) : ''} ${
prefix ? colorLog(prefix) : ''
}${message}`,
);
/* eslint-enable no-console */
if (other) {
console.log('\n', other); // eslint-disable-line no-console
}
}
function logType(type, message, other) {
const icon = iconMapping[type]
const prefix = prefixMapping[type]
const colorLog = colorLogger(type)
/* eslint-disable no-console */
console.log(
`${icon ? colorLog(fig(icon)) : ''} ${
prefix ? colorLog(prefix) : ''
}${message}`
)
/* eslint-enable no-console */
if (other) {
console.log('\n', other) // eslint-disable-line no-console
}
}
export function normalizeText(text) {
return figures(text)
.replace(/\033\[[0-9;]*m/g, '')
.replace(/\r\n|\r/g, '\n')
.trim()
.replace(/[ \t]+\n/g, '\n')
.replace(/\d+m\d{2}\.\d{3}s/, '')
.replace(/\d+(.\d+)?ms/g, 'ms')
.replace(/\//g, path.sep)
.replace(/ +/g, ' ')
.split('\n')
.map(line => line.trim())
.join('\n')
}
export const list = (entries: any[]) => {
for (const entry of entries) {
if (entry.current) {
console.log(figures('❯ ') + chalk.green(entry.name))
} else {
console.log(figures(' ') + entry.name)
}
}
}
export const list = (entries: any[]) => {
for (const entry of entries) {
if (entry.current) {
console.log(figures('❯ ') + chalk.green(entry.name))
} else {
console.log(figures(' ') + entry.name)
}
}
}
import chalk from 'chalk'
import BasicReporter from './basic'
import { parseStack } from '../utils/error'
import { chalkColor, chalkBgColor } from '../utils/chalk'
import { TYPE_COLOR_MAP, LEVEL_COLOR_MAP } from '../utils/fancy'
const DEFAULTS = {
secondaryColor: 'grey',
formatOptions: {
colors: true,
compact: false
}
}
const TYPE_ICONS = {
info: figures('ℹ'),
success: figures('✔'),
debug: figures('›'),
trace: figures('›'),
log: ''
}
export default class FancyReporter extends BasicReporter {
constructor (options) {
super(Object.assign({}, DEFAULTS, options))
}
formatStack (stack) {
const grey = chalkColor('grey')
const cyan = chalkColor('cyan')
return '\n' + parseStack(stack)