How do you set colors using either rgb or hex representation using the very popular colors module? https://npmjs.org/package/colors
I read ove documentation and don't see an option, however, it seems like such a popular module would give you this control, no?
var colors = require('colors');
colors.setTheme({
my_green: '#5A9664', // doesn't work
output: 'green',
});
console.log("A string that wants to be a color.".my_green);
update, putting one of my comments in question so it's not burried: The colors module supports Browser mode, which clearly opens up the door for #hex colors within the html tags. The setTheme doesn't support an ANSI input array, and only takes the first half. (The module would have to be smarter to wrap the string in ansi.)
Thanks.
The color format of the console cant accept these HEX color value: #XXXXXX you need to check these file:
https://github.com/Marak/colors.js/blob/master/colors.js and pass a ANSI color format value.
As the developer describes:
'bold' : ['\x1B[1m', '\x1B[22m'],
'italic' : ['\x1B[3m', '\x1B[23m'],
'underline' : ['\x1B[4m', '\x1B[24m'],
'inverse' : ['\x1B[7m', '\x1B[27m'],
'strikethrough' : ['\x1B[9m', '\x1B[29m'],
//grayscale
'white' : ['\x1B[37m', '\x1B[39m'],
'grey' : ['\x1B[90m', '\x1B[39m'],
'black' : ['\x1B[30m', '\x1B[39m'],
//colors
'blue' : ['\x1B[34m', '\x1B[39m'],
'cyan' : ['\x1B[36m', '\x1B[39m'],
'green' : ['\x1B[32m', '\x1B[39m'],
'magenta' : ['\x1B[35m', '\x1B[39m'],
'red' : ['\x1B[31m', '\x1B[39m'],
'yellow' : ['\x1B[33m', '\x1B[39m']
You can only override the existing theme properties and set pre-defined colors to specific keys
From the readme:
colors.setTheme({
silly: 'rainbow',
input: 'grey',
verbose: 'cyan',
prompt: 'grey',
info: 'green',
data: 'grey',
help: 'cyan',
warn: 'yellow',
debug: 'blue',
error: 'red'
});
For example you can set prompt to green but you cannot set prompt to a custom hex color