source: trip-planner-front/node_modules/colorette/index.js@ 59329aa

Last change on this file since 59329aa was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 2.5 KB
Line 
1import * as tty from "tty"
2
3const env = process.env
4
5const isDisabled = "NO_COLOR" in env
6const isForced = "FORCE_COLOR" in env
7const isWindows = process.platform === "win32"
8
9const isCompatibleTerminal =
10 tty && tty.isatty(1) && env.TERM && env.TERM !== "dumb"
11
12const isCI =
13 "CI" in env &&
14 ("GITHUB_ACTIONS" in env || "GITLAB_CI" in env || "CIRCLECI" in env)
15
16let enabled =
17 !isDisabled && (isForced || isWindows || isCompatibleTerminal || isCI)
18
19const raw = (open, close, searchRegex, replaceValue) => (s) =>
20 enabled
21 ? open +
22 (~(s += "").indexOf(close, 4) // skip opening \x1b[
23 ? s.replace(searchRegex, replaceValue)
24 : s) +
25 close
26 : s
27
28const init = (open, close) => {
29 return raw(
30 `\x1b[${open}m`,
31 `\x1b[${close}m`,
32 new RegExp(`\\x1b\\[${close}m`, "g"),
33 `\x1b[${open}m`
34 )
35}
36
37export const options = Object.defineProperty({}, "enabled", {
38 get: () => enabled,
39 set: (value) => (enabled = value),
40})
41
42export const reset = init(0, 0)
43export const bold = raw("\x1b[1m", "\x1b[22m", /\x1b\[22m/g, "\x1b[22m\x1b[1m")
44export const dim = raw("\x1b[2m", "\x1b[22m", /\x1b\[22m/g, "\x1b[22m\x1b[2m")
45export const italic = init(3, 23)
46export const underline = init(4, 24)
47export const inverse = init(7, 27)
48export const hidden = init(8, 28)
49export const strikethrough = init(9, 29)
50export const black = init(30, 39)
51export const red = init(31, 39)
52export const green = init(32, 39)
53export const yellow = init(33, 39)
54export const blue = init(34, 39)
55export const magenta = init(35, 39)
56export const cyan = init(36, 39)
57export const white = init(37, 39)
58export const gray = init(90, 39)
59export const bgBlack = init(40, 49)
60export const bgRed = init(41, 49)
61export const bgGreen = init(42, 49)
62export const bgYellow = init(43, 49)
63export const bgBlue = init(44, 49)
64export const bgMagenta = init(45, 49)
65export const bgCyan = init(46, 49)
66export const bgWhite = init(47, 49)
67export const blackBright = init(90, 39)
68export const redBright = init(91, 39)
69export const greenBright = init(92, 39)
70export const yellowBright = init(93, 39)
71export const blueBright = init(94, 39)
72export const magentaBright = init(95, 39)
73export const cyanBright = init(96, 39)
74export const whiteBright = init(97, 39)
75export const bgBlackBright = init(100, 49)
76export const bgRedBright = init(101, 49)
77export const bgGreenBright = init(102, 49)
78export const bgYellowBright = init(103, 49)
79export const bgBlueBright = init(104, 49)
80export const bgMagentaBright = init(105, 49)
81export const bgCyanBright = init(106, 49)
82export const bgWhiteBright = init(107, 49)
Note: See TracBrowser for help on using the repository browser.