File tree Expand file tree Collapse file tree 1 file changed +5
-9
lines changed
Expand file tree Collapse file tree 1 file changed +5
-9
lines changed Original file line number Diff line number Diff line change @@ -10,8 +10,8 @@ import (
1010)
1111
1212var (
13- _isColorEnabled bool = true
14- _isStdoutTerminal , checkedTerminal , checkedNoColor bool
13+ _isColorEnabled bool = true
14+ _isStdoutTerminal , checkedTerminal bool
1515
1616 // Outputs ANSI color if stdout is a tty
1717 Magenta = makeColorFunc ("magenta" )
@@ -45,21 +45,17 @@ func NewColorable(f *os.File) io.Writer {
4545func makeColorFunc (color string ) func (string ) string {
4646 cf := ansi .ColorFunc (color )
4747 return func (arg string ) string {
48- if isColorEnabled () && isStdoutTerminal () {
48+ if isColorEnabled () {
4949 return cf (arg )
5050 }
5151 return arg
5252 }
5353}
5454
5555func isColorEnabled () bool {
56- if ! isStdoutTerminal () {
56+ if os . Getenv ( "NO_COLOR" ) != "" {
5757 return false
5858 }
5959
60- if ! checkedNoColor {
61- _isColorEnabled = os .Getenv ("NO_COLOR" ) == ""
62- checkedNoColor = true
63- }
64- return _isColorEnabled
60+ return isStdoutTerminal ()
6561}
You can’t perform that action at this time.
0 commit comments