Merge pull request #864 from ceriath/patch-1

Remove colored output on windows
This commit is contained in:
David Bariod 2018-12-10 09:02:29 +01:00 committed by GitHub
commit 9f049671f1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 2 deletions

View File

@ -4,6 +4,7 @@ import (
"bytes" "bytes"
"fmt" "fmt"
"os" "os"
"runtime"
"sort" "sort"
"strings" "strings"
"sync" "sync"
@ -90,7 +91,7 @@ func (f *TextFormatter) init(entry *Entry) {
} }
func (f *TextFormatter) isColored() bool { func (f *TextFormatter) isColored() bool {
isColored := f.ForceColors || f.isTerminal isColored := f.ForceColors || (f.isTerminal && (runtime.GOOS != "windows"))
if f.EnvironmentOverrideColors { if f.EnvironmentOverrideColors {
if force, ok := os.LookupEnv("CLICOLOR_FORCE"); ok && force != "0" { if force, ok := os.LookupEnv("CLICOLOR_FORCE"); ok && force != "0" {

View File

@ -5,6 +5,7 @@ import (
"errors" "errors"
"fmt" "fmt"
"os" "os"
"runtime"
"sort" "sort"
"strings" "strings"
"testing" "testing"
@ -443,7 +444,11 @@ func TestTextFormatterIsColored(t *testing.T) {
os.Setenv("CLICOLOR_FORCE", val.clicolorForceVal) os.Setenv("CLICOLOR_FORCE", val.clicolorForceVal)
} }
res := tf.isColored() res := tf.isColored()
if runtime.GOOS == "windows" && !tf.ForceColors && !val.clicolorForceIsSet {
assert.Equal(subT, false, res)
} else {
assert.Equal(subT, val.expectedResult, res) assert.Equal(subT, val.expectedResult, res)
}
}) })
} }
} }