Open stylemistake opened 2 years ago
formatUtils
is used everywhere, for example the message name here:
https://github.com/yarnpkg/berry/blob/master/packages/yarnpkg-core/sources/StreamReport.ts#L91
On the flip side, today we still see the option ignored but to the opposite effect:
Colored output is enabled in GitHub Actions (making testing of process output an unnecessary hassle) and setting YARN_ENABLE_COLORS=false
env var does not take any effect.
Can not reproduce it locally. It seems like chalk colors are force-enabled if yarn detects running in GitHub Actions. Surprising.
Describe the user story
I often run Yarn as part of a build pipeline, often in parallel, both in CI and locally on a dev machine, where Yarn doesn't have access to TTY. It is very desirable to have support for colors when you can ensure that terminal supports it regardless of TTY checks.
Documentation for
.yarnrc.yml
has the following:Well, the problem is that when TTY is not present, this option is completely ignored (not really, but kind of yes), which is kinda against documentation.
You can reproduce it with something like this:
The only exception to this is the
yarn config
module, which prints out colors successfully (but not for the> YN0000
part).Describe the solution you'd like
That's the hard part, because I initially thought this was a bug, but the more I look into the code, it appears more like a missing feature. The only code that respects the
enableColors
config option is theformatUtils
module,andformatUtils
seems to be barely used anywhere (correct me if I'm wrong).Would be nice if all formatting code was aware of this option.
Describe the drawbacks of your solution
Might require a lot of actual work instead of fixing a small issue.
Describe alternatives you've considered
Perhaps it could be overridden globally on
chalk
module level, and all code that depends on chalk would automatically output in colors in respect to that setting.