File tree Expand file tree Collapse file tree 1 file changed +6
-7
lines changed
Expand file tree Collapse file tree 1 file changed +6
-7
lines changed Original file line number Diff line number Diff line change @@ -10,8 +10,7 @@ import (
1010)
1111
1212var (
13- _isColorEnabled bool = true
14- _isStdoutTerminal , checkedTerminal , checkedNoColor bool
13+ _isStdoutTerminal , checkedTerminal bool
1514
1615 // Outputs ANSI color if stdout is a tty
1716 Magenta = makeColorFunc ("magenta" )
@@ -45,17 +44,17 @@ func NewColorable(f *os.File) io.Writer {
4544func makeColorFunc (color string ) func (string ) string {
4645 cf := ansi .ColorFunc (color )
4746 return func (arg string ) string {
48- if isColorEnabled () && isStdoutTerminal () {
47+ if isColorEnabled () {
4948 return cf (arg )
5049 }
5150 return arg
5251 }
5352}
5453
5554func isColorEnabled () bool {
56- if ! checkedNoColor {
57- _isColorEnabled = os .Getenv ("NO_COLOR" ) == ""
58- checkedNoColor = true
55+ if os .Getenv ("NO_COLOR" ) != "" {
56+ return false
5957 }
60- return _isColorEnabled
58+
59+ return isStdoutTerminal ()
6160}
You can’t perform that action at this time.
0 commit comments