-
-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix NO_COLOR handling to comply with the spec #40
Conversation
disable color with NO_COLOR: before: $ NO_COLOR=1 command # ✔ $ NO_COLOR=0 command # ✔ $ NO_COLOR= command # x $ NO_COLOR="" command # x after: $ NO_COLOR=1 command # ✔ $ NO_COLOR=0 command # ✔ $ NO_COLOR= command # ✔ $ NO_COLOR="" command # ✔ also: - don't equate FORCE_COLOR="" with FORCE_COLOR=1 - add environment-variable tests (based on ./test/env.sh)
Codecov Report
@@ Coverage Diff @@
## master #40 +/- ##
==========================================
- Coverage 98.77% 97.60% -1.17%
==========================================
Files 2 2
Lines 163 167 +4
Branches 31 32 +1
==========================================
+ Hits 161 163 +2
- Misses 1 3 +2
Partials 1 1
Continue to review full report at Codecov.
|
Hey, FORCE_COLOR logic is the same as chalk's Also, I really appreciate you taking time to modify tests, but I'm very hesitant of moving the ENV tests to something else entirely. Do you mind reverting those changes and just adding new test cases to the bash file there? Thank you |
I went with #39 for the code fix because it arrived first, but definitely looking out for your test additions! |
I don't think it is, but then chalk's "logic" makes very little sense to me either way.
I restored your Anyway, closing this since the other PR fixes the |
It's the same through this line: https://github.com/chalk/supports-color/blob/c5edf46896d1fc1826cb1183a60d61eecb65d749/index.js#L27 An empty string will force it to be 1 I agree it doesn't make sense but we're stuck respecting someone else's decisions -- just like NO_COLOR Do you plan on adding the bash changes? |
I don't think there's anything to learn, really. It's declarative, and IMO much clearer than If you know bash, then you know Bats. If you don't know bash, Bats is the best way to avoid it :-) |
Closes #38
disable color with NO_COLOR:
before:
after:
also:
FORCE_COLOR=""
withFORCE_COLOR=1
test/env.sh
)Note that the 4 tests which combine
NO_COLOR
andFORCE_COLOR
fail on Node.js >= v12 because it has elected to issue a warning if both are defined.