Skip to content

Commit

Permalink
Merge pull request sirupsen#864 from ceriath/patch-1
Browse files Browse the repository at this point in the history
Remove colored output on windows
  • Loading branch information
dgsb committed Dec 10, 2018
2 parents f8013bd + 00f1514 commit a4d0171
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
3 changes: 2 additions & 1 deletion text_formatter.go
Expand Up @@ -4,6 +4,7 @@ import (
"bytes"
"fmt"
"os"
"runtime"
"sort"
"strings"
"sync"
Expand Down Expand Up @@ -90,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 Down
7 changes: 6 additions & 1 deletion text_formatter_test.go
Expand Up @@ -5,6 +5,7 @@ import (
"errors"
"fmt"
"os"
"runtime"
"sort"
"strings"
"testing"
Expand Down Expand Up @@ -443,7 +444,11 @@ func TestTextFormatterIsColored(t *testing.T) {
os.Setenv("CLICOLOR_FORCE", val.clicolorForceVal)
}
res := tf.isColored()
assert.Equal(subT, val.expectedResult, res)
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 a4d0171

Please sign in to comment.