Skip to content

Commit

Permalink
respect ForceColor and environment variables over OS check
Browse files Browse the repository at this point in the history
  • Loading branch information
ceriath committed Dec 9, 2018
1 parent f1b98e4 commit d962013
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions text_formatter.go
Expand Up @@ -91,7 +91,7 @@ func (f *TextFormatter) init(entry *Entry) {
}

func (f *TextFormatter) isColored() bool {
isColored := f.ForceColors || f.isTerminal
isColored := f.ForceColors || (f.isTerminal && (runtime.GOOS != "windows"))

if f.EnvironmentOverrideColors {
if force, ok := os.LookupEnv("CLICOLOR_FORCE"); ok && force != "0" {
Expand All @@ -103,7 +103,7 @@ func (f *TextFormatter) isColored() bool {
}
}

return isColored && !f.DisableColors && (runtime.GOOS != "windows")
return isColored && !f.DisableColors
}

// Format renders a single log entry
Expand Down
2 changes: 1 addition & 1 deletion text_formatter_test.go
Expand Up @@ -444,7 +444,7 @@ func TestTextFormatterIsColored(t *testing.T) {
os.Setenv("CLICOLOR_FORCE", val.clicolorForceVal)
}
res := tf.isColored()
if runtime.GOOS == "windows" {
if runtime.GOOS == "windows" && !tf.ForceColors && !val.clicolorForceIsSet {
assert.Equal(subT, false, res)
} else {
assert.Equal(subT, val.expectedResult, res)
Expand Down

0 comments on commit d962013

Please sign in to comment.