Marak / colors.js

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

Undesired behavior in Cygwin? #136

Closed echobops closed 6 years ago

echobops commented 9 years ago

For the longest time, I thought cygwin was dumb in that it didn't support colors outputted by colors.js. While cygwin might be dumb in other areas, I know it at least supports colors.

Looking at supports-colors.js and seeing its tests, I found that node/cygwin has process.stdout.isTTY as undefined. That test comes before all these others (below) which a few would at least pass:

process.platform returns win32, but is placed beneath the isTTY check. For me, process.env.TERM returns xterm-256color The default for cygwin is now xterm (not cygwin as the test checks for), but can be set to xterm-256color.

I could even set an env variable COLORTERM, but it wouldn't get hit because of the location of the isTTY check.

If the isTTY test were below a few of the other ones, cygwin would work with colors by default and without having to use --colors.
echobops commented 9 years ago

Setting process.stdout.isTTY = true; before importing colors works, but that doesn't seem to be an ideal solution as you may want to run your app from something that doesn't support colors.

DABH commented 6 years ago

How does it work now with colors@next?

DABH commented 6 years ago

Closing this due to lack of activity. Thanks!