Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
getItemProps (index) {
const logItem = this.logData[index]
const isAnsi = hasAnsi(logItem.data)
return {
// will render with itemProps.
// https://vuejs.org/v2/guide/render-function.html#createElement-Arguments
props: {
index: logItem.index,
data: isAnsi ? convert.toHtml(logItem.data) : logItem.data,
isAnsi
}
}
}
},
test.serial(`should colorize the error | ${title}`, async t => {
const { stopLogging, log } = startLogging({ log: 'spy', eventName })
await emit()
t.true(log.calledOnce)
t.false(hasAnsi(String(log.firstCall.args[0])))
t.false(hasAnsi(log.firstCall.args[0].stack))
t.is(hasAnsi(inspect(log.firstCall.args[0])), Boolean(supportsColor.stdout))
stopLogging()
})
test.serial(`should colorize the error | ${title}`, async t => {
const { stopLogging, log } = startLogging({ log: 'spy', eventName })
await emit()
t.true(log.calledOnce)
t.false(hasAnsi(String(log.firstCall.args[0])))
t.false(hasAnsi(log.firstCall.args[0].stack))
t.is(hasAnsi(inspect(log.firstCall.args[0])), Boolean(supportsColor.stdout))
stopLogging()
})
test(`Prints headers in colors | ${title}`, async t => {
const { stderr } = await run('', TEST_VERSION, 'node --version', {
env: { FORCE_COLOR: '1' },
})
t.true(hasAnsi(stderr))
})
})
test(value: any) {
return typeof value === 'string' && hasAnsi(value);
},
};
private colorMessage(message: string, prefixColor: any, messageColor?: any): string {
if (hasAnsi(message)) {
return config.vpdb.logging.console.colored ? message : stripAnsi(message);
}
if (!config.vpdb.logging.console.colored) {
return message;
}
const match = message.match(/^(\[[^\]]+])(.+)/);
if (match) {
let prefix: string;
if (prefixColor == null) {
const m = match[1].split('.');
prefix = m.length === 2 ?
'[' + chalk.cyan(m[0].substring(1)) + '.' + chalk.blueBright(m[1].substring(0, m[1].length - 1)) + ']' :
'[' + chalk.cyan(match[1].substring(1, match[1].length - 1)) + ']';
} else {
prefix = prefixColor(match[1]);
}
function createRow (ln, content) {
content = content || '';
if (hasAnsi(content)) {
content = ansi.toHtml(content);
}
return `
${ln}
${content}
`;
}
renderMessageContent({ msg, level }) {
if (!hasAnsi(msg)) {
return (
<div>
{msg}
</div>
);
}
const chunks = ansiToJson(msg, {
remove_empty: true,
});
const content = chunks.map(chunk => {
const style = {};
if (chunk.bg) {