Skip to content

Commit d962013

Browse files
committed
respect ForceColor and environment variables over OS check
1 parent f1b98e4 commit d962013

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

text_formatter.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ func (f *TextFormatter) init(entry *Entry) {
9191
}
9292

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

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

106-
return isColored && !f.DisableColors && (runtime.GOOS != "windows")
106+
return isColored && !f.DisableColors
107107
}
108108

109109
// Format renders a single log entry

text_formatter_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ func TestTextFormatterIsColored(t *testing.T) {
444444
os.Setenv("CLICOLOR_FORCE", val.clicolorForceVal)
445445
}
446446
res := tf.isColored()
447-
if runtime.GOOS == "windows" {
447+
if runtime.GOOS == "windows" && !tf.ForceColors && !val.clicolorForceIsSet {
448448
assert.Equal(subT, false, res)
449449
} else {
450450
assert.Equal(subT, val.expectedResult, res)

0 commit comments

Comments
 (0)