-
Notifications
You must be signed in to change notification settings - Fork 51
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
Add support for CI envs in colour support check #62
Conversation
index.js
Outdated
const {env} = process; | ||
|
||
const isDisabled = "NO_COLOR" in env | ||
const isForced = "FORCE_COLOR" in env | ||
const isWindows = process.platform === "win32" | ||
|
||
const isCompatibleTerminal = (process.stdout != null && | ||
process.stdout.isTTY && | ||
env.TERM && | ||
env.TERM !== "dumb") | ||
|
||
const isCI = ('CI' in env && ['CIRCLECI', 'GITLAB_CI', 'GITHUB_ACTIONS'].some(sign => sign in env)) | ||
|
||
let enabled = (!isDisabled) && | ||
(isForced || isWindows || isCompatibleTerminal || isCI) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we do without the destructuring assignment (I know it's a bit strange, but we technically still support pre Node 6) and format the expression to this:
const env = process.env
const isDisabled = "NO_COLOR" in env
const isForced = "FORCE_COLOR" in env
const isWindows = process.platform === "win32"
const isCompatibleTerminal =
process.stdout != null &&
process.stdout.isTTY &&
env.TERM &&
env.TERM !== "dumb"
const isCI =
"CI" in env &&
("GITHUB_ACTIONS" in env || "GITLAB_CI" in env || "CIRCLECI" in env)
let enabled =
!isDisabled && (isForced || isWindows || isCompatibleTerminal || isCI)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
@kibertoad Just checking, but does it make sense to automatically enable color inside a CI? I thought we'd want to disable it instead. Maybe I'm having a time-lapse. |
@jorgebucaran It makes reading logs in CI console easier, and also this is a default behaviour for |
Gotcha. 👍 |
fixes #61