Marak / colors.js

get colors in your node.js console
https://github.com/Marak/colors.js
Other
5.17k stars 446 forks source link

.setTheme() is not working #198

Closed MickL closed 6 years ago

MickL commented 7 years ago
const colors = require('colors');

colors.setTheme({
    success: '#3c763d',
    info: '#31708f',
    warning: '#8a6d3b',
    error: '#a94442'
});

console.log('hello there'.info);

throws:

colors[theme[prop]] is not a function

While default colors are working: console.log('hello there'.yellow);

SUpermin6u commented 6 years ago

only support these props: { silly: 'rainbow', input: 'grey', verbose: 'cyan', prompt: 'grey', info: 'green', data: 'grey', help: 'cyan', warn: 'yellow', debug: 'blue', error: 'red' }

sn8to commented 6 years ago

Same issue here, I have included the stack trace below in case it is needed.

<project folder>\node_modules\colors\lib\extendStringPrototype.js:89
              ret = colors[theme[prop][t]](ret);
                                          ^

TypeError: colors[theme[prop][t]] is not a function
    at String.info (<project folder>\node_modules\colors\lib\extendStringPrototype.js:89:43)
    at Object.<anonymous> (<project folder>\index.js:14:21)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.runMain (module.js:604:10)
    at run (bootstrap_node.js:394:7)
    at startup (bootstrap_node.js:149:9)
sn8to commented 6 years ago

Screenshot of the source code around the area it produced the error image

steveblue commented 6 years ago

Same issue here: TypeError: colors.verbose is not a function

DABH commented 6 years ago

If I use a built-in color name like green in OP's example, everything works fine. So I believe this is not a bug with defining a custom theme; rather, it's just that colors.js doesn't support custom hex colors like that right now. That is one of the big features we have planned for an upcoming release though.

Please feel free to re-open if it seems like I'm missing something, thanks!