r2g
r2g copied to clipboard
get colors in script with no deps
https://github.com/nodejs/node/issues/21789
const colors = {
'bold': [1, 22],
'italic': [3, 23],
'underline': [4, 24],
'inverse': [7, 27],
'white': [37, 39],
'grey': [90, 39],
'black': [30, 39],
'blue': [34, 39],
'cyan': [36, 39],
'green': [32, 39],
'magenta': [35, 39],
'red': [31, 39],
'yellow': [33, 39]
};
function stylize(color, str) {
const [start, end] = colors[color];
return `\u001b[${start}m${str}\u001b[${end}m`;
}