gjtorikian / html-proofer

Test your rendered HTML files to make sure they're accurate.
MIT License
1.57k stars 199 forks source link

Allow color in non tty shell #817

Closed sam-mcbr closed 5 months ago

sam-mcbr commented 6 months ago

I would like to use html-proofer in a CI job, but since the running is not a TTY shell there is no color output. Would love an environment variable or command line argument to force color output. Thanks!

gjtorikian commented 6 months ago

Can you try setting the environment variable CLICOLOR_FORCE = '1' ?

sam-mcbr commented 6 months ago

Thanks for the quick response! Unfortunately still showing uncolored text

gjtorikian commented 6 months ago

Would it be possible to see how you're setting that env var, or a sample workflow?

Terminal color output is dependent on https://github.com/ku1ik/rainbow/blob/138bc054cd196b54ed6a935c52653a8ac3761dfc/lib/rainbow.rb#L10-L12

html-proofer isn't doing any TTY determination, so I'm surprised the underlying library's mechanism isn't working.

sam-mcbr commented 6 months ago

Sorry for the delay, yeah I can share an example of how I was setting the var soon. But the reason I thought the TTY would affect this is I saw this line where Rainbow is only invoked if stdout is a TTY: https://github.com/gjtorikian/html-proofer/blob/1c8b2c12474d3e60401dd6200c2c72833af2ac31/lib/html_proofer/log.rb#L44

Could this be the cause of no color even with the env var set?

gjtorikian commented 6 months ago

I guess Rainbow updated its logic at some point, because I see now that it handles TTY/color enabling on its own.

Could you try the branch at https://github.com/gjtorikian/html-proofer/pull/818 and see if that works for you?

sam-mcbr commented 5 months ago

@gjtorikian Apologies for the long delay, I was able to confirm that this change enables colored output!

gjtorikian commented 5 months ago

No worries, glad it worked, I'll send this out as 5.0.9 soon.