tutanota/packages/otest/lib/fancy.ts
wrd 88355bd5d1 Splits MailModel into two, adding MailboxModel
close pi#214

Calendar only needs access to MailboxModel, MailModel handles deleting
and moving mails
2024-09-23 16:49:37 +02:00

19 lines
458 B
TypeScript

export const ansiSequences = Object.freeze({
redFg: "\x1b[31m",
greenBg: "\x1b[42m",
redBg: "\x1b[41m",
yellowBg: "\x1b[43m",
reset: "\x1b[0m",
bold: "\x1b[0;1m",
faint: "\x1b[0;2m",
})
type CodeValues = typeof ansiSequences[keyof typeof ansiSequences]
export function fancy(text: string, code: CodeValues) {
if (typeof process !== "undefined" && process.stdout.isTTY) {
return `${code}${text}${ansiSequences.reset}`
} else {
return text
}
}