You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
66 lines
1.2 KiB
JavaScript
66 lines
1.2 KiB
JavaScript
5 years ago
|
'use strict';
|
||
|
|
||
|
function assembleStyles () {
|
||
|
var styles = {
|
||
|
modifiers: {
|
||
|
reset: [0, 0],
|
||
|
bold: [1, 22], // 21 isn't widely supported and 22 does the same thing
|
||
|
dim: [2, 22],
|
||
|
italic: [3, 23],
|
||
|
underline: [4, 24],
|
||
|
inverse: [7, 27],
|
||
|
hidden: [8, 28],
|
||
|
strikethrough: [9, 29]
|
||
|
},
|
||
|
colors: {
|
||
|
black: [30, 39],
|
||
|
red: [31, 39],
|
||
|
green: [32, 39],
|
||
|
yellow: [33, 39],
|
||
|
blue: [34, 39],
|
||
|
magenta: [35, 39],
|
||
|
cyan: [36, 39],
|
||
|
white: [37, 39],
|
||
|
gray: [90, 39]
|
||
|
},
|
||
|
bgColors: {
|
||
|
bgBlack: [40, 49],
|
||
|
bgRed: [41, 49],
|
||
|
bgGreen: [42, 49],
|
||
|
bgYellow: [43, 49],
|
||
|
bgBlue: [44, 49],
|
||
|
bgMagenta: [45, 49],
|
||
|
bgCyan: [46, 49],
|
||
|
bgWhite: [47, 49]
|
||
|
}
|
||
|
};
|
||
|
|
||
|
// fix humans
|
||
|
styles.colors.grey = styles.colors.gray;
|
||
|
|
||
|
Object.keys(styles).forEach(function (groupName) {
|
||
|
var group = styles[groupName];
|
||
|
|
||
|
Object.keys(group).forEach(function (styleName) {
|
||
|
var style = group[styleName];
|
||
|
|
||
|
styles[styleName] = group[styleName] = {
|
||
|
open: '\u001b[' + style[0] + 'm',
|
||
|
close: '\u001b[' + style[1] + 'm'
|
||
|
};
|
||
|
});
|
||
|
|
||
|
Object.defineProperty(styles, groupName, {
|
||
|
value: group,
|
||
|
enumerable: false
|
||
|
});
|
||
|
});
|
||
|
|
||
|
return styles;
|
||
|
}
|
||
|
|
||
|
Object.defineProperty(module, 'exports', {
|
||
|
enumerable: true,
|
||
|
get: assembleStyles
|
||
|
});
|