-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcolor.js
58 lines (56 loc) · 1.03 KB
/
color.js
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
var styles = {
bold: [1, 22],
italic: [3, 23],
diminish: [2, 22],
underline: [4, 24],
// color
black: 30,
red: 31,
green: 32,
yellow: 33,
blue: 34,
magenta: 35,
cyan: 36,
white: 37,
gray: 90,
// Bright color
redBright: 91,
greenBright: 92,
yellowBright: 93,
blueBright: 94,
magentaBright: 95,
cyanBright: 96,
whiteBright: 97,
// close color
colorClose: 39,
// bgColor
bgBlack: 40,
bgRed: 41,
bgGreen: 42,
bgYellow: 43,
bgBlue: 44,
bgMagenta: 45,
bgCyan: 46,
bgWhite: 47,
// Bright bg color
bgBlackBright: 100,
bgRedBright: 101,
bgGreenBright: 102,
bgYellowBright: 103,
bgBlueBright: 104,
bgMagentaBright: 105,
bgCyanBright: 106,
bgWhiteBright: 107,
// close bgColor
bgColorClose: 49
};
Object.keys(styles).forEach(function(key) {
if (Array.isArray(styles[key])) {
styles[key] = styles[key].map(function(code) {
return '\u001B[' + code + 'm';
});
} else {
styles[key] = '\u001B[' + styles[key] + 'm';
}
});
module.exports = styles;