@cotype/core
Version:
<h2 align="center"> <img src="https://cotype.dev/logo.svg" alt="cotype" /> </h2>
45 lines (41 loc) • 1.11 kB
text/typescript
import chalk from "chalk";
function highlight(
text: string | number | boolean,
background: string = "#555555",
color: string = "#ffffff"
) {
if (!chalk.supportsColor) {
return text;
}
return chalk.bgHex(background)(chalk.hex(color)(chalk.bold(text.toString())));
}
function logo(background: string = "#FB249D", color: string = "#ffffff") {
if (!chalk.supportsColor) {
return "[cotype]";
}
return highlight(" { ", background, color);
}
export default {
debug(...args: any[]) {
console.debug(logo("#777777"), ...args);
},
log(...args: any[]) {
// tslint:disable-next-line:no-console
console.log(logo("#555555"), ...args);
},
warn(...args: any[]) {
console.warn(logo("#f9a022"), ...args);
},
error(...args: any[]) {
console.warn(logo("#f94622"), ...args);
},
info(...args: any[]) {
console.debug(logo(), ...args);
},
color(background: string = "#FB249D", color: string = "#ffffff") {
// tslint:disable-next-line:no-console
return (...args: any[]) => console.log(logo(background, color), ...args);
},
highlight,
logo
};