A11y: support NO_COLOR environment variable in output - #303
A11y: support NO_COLOR environment variable in output#303MaddyGuthridge wants to merge 2 commits into
Conversation
krzysdz
left a comment
There was a problem hiding this comment.
I believe that NO_COLOR=1 should entirely remove the colour-related ANSI escape codes instead of emitting the reset sequence.
|
Makes sense to me, although that would require a bit of a bigger refactor. I am pretty flat-out right now so probably won't have time to sort that out for a few weeks at least. I'll keep it on my todo list though. |
|
I have an idea that may be a little weird, but should work - after the current /**
* NO_COLOR override of dev
*/
if (process.env.NO_COLOR) {
morgan.format('dev', ':method :url :status :response-time ms - :res[content-length]')
}It assumes that the Lines 480 to 491 in bd171d7 Alternatively, the Lines 107 to 110 in bd171d7 This would make testing easier, but IMO would negatively impact the code structure (suddenly one format is defined inside @jonchurch @UlisesGascon do you think this would be an acceptable solution? |
|
Based on #303 (comment), I think that #372 supperseeds this pr 🤔 |
Resolves #302
This is a quick fix, rather than a major change to the system Morgan uses for styled console output. In an ideal world, using
NO_COLORwould disable all styling of output, which would remove the presence of control characters in things like CI logs. Currently, this PR just sets the color to0ifNO_COLORis set inprocess.env, which is acceptable for accessibility.As a side note: I'm not used to writing code for such old versions of Node, so apologies if I made any mistakes that break that compatibility. I tried testing using Node 0.8.28, but was unable to get
npm ito work correctly. Let me know if I broke anything and I'll do my best to fix it up :)I accept the certificate of origin, and am happy for my contribution to use the project's MIT software license.