Skip to content
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

Remove colored output on windows #864

Merged
merged 3 commits into from Dec 10, 2018
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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 @@ -102,7 +103,7 @@ func (f *TextFormatter) isColored() bool {
}
}

return isColored && !f.DisableColors
return isColored && !f.DisableColors && (runtime.GOOS != "windows")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello, I would like that the ForceColor field of the text formatter takes precedence on the environment check.
I expect that then this flag is set to true the user knows what he is doing.

}

// Format renders a single log entry
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" {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need to updated the test for windows environment where isColored always return false except when ForceColor is set to true.

assert.Equal(subT, false, res)
} else {
assert.Equal(subT, val.expectedResult, res)
}
})
}
}
Expand Down