/
githubmirror
/
nest
Обзор
Документация
Войти
/
githubmirror
/
nest
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
packages/common/utils/cli-colors.util.ts
17 строк
761 B
Kerry
Export isColorAllowed function for external use
28 авг 2025, 08:53
Не верифицирован
28 авг 2025, 08:53
a117a2a
Код
Авторство
О чём код?
type ColorTextFn = (text: string) => string; export const isColorAllowed = () => !process.env.NO_COLOR; const colorIfAllowed = (colorFn: ColorTextFn) => (text: string) => isColorAllowed() ? colorFn(text) : text; export const clc = { bold: colorIfAllowed((text: string) => `\x1B[1m${text}\x1B[0m`), green: colorIfAllowed((text: string) => `\x1B[32m${text}\x1B[39m`), yellow: colorIfAllowed((text: string) => `\x1B[33m${text}\x1B[39m`), red: colorIfAllowed((text: string) => `\x1B[31m${text}\x1B[39m`), magentaBright: colorIfAllowed((text: string) => `\x1B[95m${text}\x1B[39m`), cyanBright: colorIfAllowed((text: string) => `\x1B[96m${text}\x1B[39m`), }; export const yellow = colorIfAllowed( (text: string) => `\x1B[38;5;3m${text}\x1B[39m`, );