Marak / colors.js

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

colors.red(null) doesn't work #238

Closed novalis closed 6 years ago

novalis commented 6 years ago

colors.red(undefined) does work. Looks like you need to check for null when checking for undefined in https://github.com/Marak/colors.js/blob/f35d715e046cf07c41f7d31eb57d6c16ed4d0f4d/lib/colors.js#L108

Also, even if I fix the above, somehow, null makes it down to https://github.com/Marak/colors.js/blob/master/lib/custom/zalgo.js#L70 without being turned into a string. Expected result: ̵̲̩T̟h̺̩͚̞͚̰̖̀e͏̹̭͎̫ ̳̯̤̭̪N͟e̢̪̰͔̫z̞ͅp̛͉e̞ṟ̬̬̙͈̀d͡i̛̻̥͍̟͓a̬̫̱n̤͉̙͈̣̹͚ ̵h̺̲͚̱̠͎i͏̜̰̦̳̞̫v̹̼̠͙e҉̖͉͍̤ͅ-̱̖͈̰̺̪m̰̤̦̩ͅi̝͖̹̼̦̦̳n̞̗̲̳͍̳̩d̛̞̬ ̬̀o͏̳̣͙̻͎̥f͙̭̮̣͢ͅ ͠c̩ͅh̻̮̩̜̗a̳͉̪̜o͓s̵͈̣̗͔͉̣.̴̝͙ ̩̩̙̱Z̼͉̬̞̥͚̼a̖̼̰̭̱l̗̥̥̠̜̬͓g̵̪̬̫͙o̥͉̲̮ͅ. Actual result:

     TypeError: text.split is not a function
      at heComes (node_modules/colors/lib/custom/zalgo.js:70:17)

and he doesn't come.

DABH commented 6 years ago

Hmm, That does seem like a bug. If you have time to figure this out, that would be great, and we’d be happy to consider a PR. Otherwise, I will try to find time to look into this at some point. Thanks for reporting this either way!

novalis commented 6 years ago

The change I made locally that fixes the first case is just to add a check for null next to the check for undefined; for the second case, I checked for null and then set it to "null". I can't easily do a PR because I would have to get corporate permission and I can't really justify that for a two-line change. So sorry to be annoying here.

DABH commented 6 years ago

No problem. This should be fixed by https://github.com/Marak/colors.js/commit/654f2b67e375e26c4a932f9fb0f1f2ce11888562 . I tested and colorizing null works in safe mode now, but I was unable to reproduce any issues with Zalgo. If you have a specific way to reproduce any other errors let me know. Otherwise this fix will go out in the next release.

DABH commented 6 years ago

(fix published as 1.3.2)

novalis commented 6 years ago

I also can no longer repro the Zalgo issue.

Thanks for the fix.

givehug commented 5 years ago

Hi guys, I'm using 1.3.3 and the code snippet is till

if (arg !== undefined && arg.constructor === String) {

I guess it was never released. Created follow up PR.