Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
81159 views
1
'use strict';
2
3
var styles = module.exports = {
4
modifiers: {
5
reset: [0, 0],
6
bold: [1, 22], // 21 isn't widely supported and 22 does the same thing
7
dim: [2, 22],
8
italic: [3, 23],
9
underline: [4, 24],
10
inverse: [7, 27],
11
hidden: [8, 28],
12
strikethrough: [9, 29]
13
},
14
colors: {
15
black: [30, 39],
16
red: [31, 39],
17
green: [32, 39],
18
yellow: [33, 39],
19
blue: [34, 39],
20
magenta: [35, 39],
21
cyan: [36, 39],
22
white: [37, 39],
23
gray: [90, 39]
24
},
25
bgColors: {
26
bgBlack: [40, 49],
27
bgRed: [41, 49],
28
bgGreen: [42, 49],
29
bgYellow: [43, 49],
30
bgBlue: [44, 49],
31
bgMagenta: [45, 49],
32
bgCyan: [46, 49],
33
bgWhite: [47, 49]
34
}
35
};
36
37
// fix humans
38
styles.colors.grey = styles.colors.gray;
39
40
Object.keys(styles).forEach(function (groupName) {
41
var group = styles[groupName];
42
43
Object.keys(group).forEach(function (styleName) {
44
var style = group[styleName];
45
46
styles[styleName] = group[styleName] = {
47
open: '\u001b[' + style[0] + 'm',
48
close: '\u001b[' + style[1] + 'm'
49
};
50
});
51
52
Object.defineProperty(styles, groupName, {
53
value: group,
54
enumerable: false
55
});
56
});
57
58