blob: 709d159320d1ce266f0b5a9b6ade409967fff3b9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
|
/**
* The interface used for formatting strings to contain color metadata.
*
* Use the interface properties to construct a style, then use the
* `(s: string): string` function to format the provided string with the given
* style.
*/
export interface Colors {
// Are colors enabled?
enabled: boolean;
// Returns the string formatted to contain the specified color or style.
(s: string): string;
// modifiers
reset: Colors;
bold: Colors;
dim: Colors;
italic: Colors;
underline: Colors;
inverse: Colors;
hidden: Colors;
strikethrough: Colors;
// colors
black: Colors;
red: Colors;
green: Colors;
yellow: Colors;
blue: Colors;
magenta: Colors;
cyan: Colors;
white: Colors;
gray: Colors;
grey: Colors;
// bright colors
blackBright: Colors;
redBright: Colors;
greenBright: Colors;
yellowBright: Colors;
blueBright: Colors;
magentaBright: Colors;
cyanBright: Colors;
whiteBright: Colors;
// background colors
bgBlack: Colors;
bgRed: Colors;
bgGreen: Colors;
bgYellow: Colors;
bgBlue: Colors;
bgMagenta: Colors;
bgCyan: Colors;
bgWhite: Colors;
// bright background colors
bgBlackBright: Colors;
bgRedBright: Colors;
bgGreenBright: Colors;
bgYellowBright: Colors;
bgBlueBright: Colors;
bgMagentaBright: Colors;
bgCyanBright: Colors;
bgWhiteBright: Colors;
}
/**
* The interface used for formatting strings with color metadata.
*
* Currently Colors will use the 'ansi-colors' module if it can be loaded.
* If it cannot be loaded, then the Colors implementation is a straight pass-through.
*
* Colors may also be a no-op if the current environment does not support colors.
*/
export let Colors: Colors;
try {
/* eslint-disable-next-line node/no-unpublished-require */
Colors = require('ansi-colors') as Colors;
} catch {
const passthrough = ((s: string) => s) as Colors;
passthrough.enabled = false;
passthrough.reset = passthrough;
passthrough.bold = passthrough;
passthrough.dim = passthrough;
passthrough.italic = passthrough;
passthrough.underline = passthrough;
passthrough.inverse = passthrough;
passthrough.hidden = passthrough;
passthrough.strikethrough = passthrough;
passthrough.black = passthrough;
passthrough.red = passthrough;
passthrough.green = passthrough;
passthrough.yellow = passthrough;
passthrough.blue = passthrough;
passthrough.magenta = passthrough;
passthrough.cyan = passthrough;
passthrough.white = passthrough;
passthrough.gray = passthrough;
passthrough.grey = passthrough;
passthrough.blackBright = passthrough;
passthrough.redBright = passthrough;
passthrough.greenBright = passthrough;
passthrough.yellowBright = passthrough;
passthrough.blueBright = passthrough;
passthrough.magentaBright = passthrough;
passthrough.cyanBright = passthrough;
passthrough.whiteBright = passthrough;
passthrough.bgBlack = passthrough;
passthrough.bgRed = passthrough;
passthrough.bgGreen = passthrough;
passthrough.bgYellow = passthrough;
passthrough.bgBlue = passthrough;
passthrough.bgMagenta = passthrough;
passthrough.bgCyan = passthrough;
passthrough.bgWhite = passthrough;
passthrough.bgBlackBright = passthrough;
passthrough.bgRedBright = passthrough;
passthrough.bgGreenBright = passthrough;
passthrough.bgYellowBright = passthrough;
passthrough.bgBlueBright = passthrough;
passthrough.bgMagentaBright = passthrough;
passthrough.bgCyanBright = passthrough;
passthrough.bgWhiteBright = passthrough;
Colors = passthrough;
}
|