本文整理汇总了TypeScript中chalk.Chalk.default方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Chalk.default方法的具体用法?TypeScript Chalk.default怎么用?TypeScript Chalk.default使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类chalk.Chalk
的用法示例。
在下文中一共展示了Chalk.default方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: highlightTrailingSpaces
const highlightLeadingTrailingSpaces = (line: string, bgColor: Chalk): string =>
// If line consists of ALL spaces: highlight all of them.
highlightTrailingSpaces(line, bgColor).replace(
// If line has an ODD length of leading spaces: highlight only the LAST.
/^(\s\s)*(\s)(?=[^\s])/,
'$1' + bgColor('$2'),
);
示例2: catch
ws.on('message', data => {
let msg;
try {
data = data.toString();
msg = JSON.parse(data);
} catch (e) {
process.stderr.write(`Error parsing JSON message from dev server: "${data}" ${chalk.red(e.stack ? e.stack : e)}\n`);
return;
}
if (!isDevServerMessage(msg)) {
const m = util.inspect(msg, { colors: chalk.enabled });
process.stderr.write(`Bad format in dev server message: ${m}\n`);
return;
}
if (msg.category === 'console') {
let status: Chalk | undefined; // unknown levels are normal color
if (msg.type === 'info' || msg.type === 'log') {
status = chalk.reset;
} else if (msg.type === 'error') {
status = chalk.red;
} else if (msg.type === 'warn') {
status = chalk.yellow;
}
if (status) {
process.stdout.write(`[${status('console.' + msg.type)}]: ${msg.data.join(' ')}\n`);
} else {
process.stdout.write(`[console]: ${msg.data.join(' ')}\n`);
}
}
});
示例3: color
return content.replace(regex, (item, pos, originalText) => {
return color(this.applyBinding(item, model, 2));
});
示例4: logger
? (message: string) => logger(stderrConsole, yellow(message))
示例5: bgColor
const highlightTrailingSpaces = (line: string, bgColor: Chalk): string =>
line.replace(/\s+$/, bgColor('$&'));