File tree Expand file tree Collapse file tree 2 files changed +17
-5
lines changed
Expand file tree Collapse file tree 2 files changed +17
-5
lines changed Original file line number Diff line number Diff line change @@ -31,12 +31,13 @@ func Test(t *testing.T) {
3131
3232## Color
3333
34- To turn off the colors, run ` go test ` with the ` -nocolor ` flag, or with the env var ` IS_NO_COLOR=true ` .
34+ To turn off the colors, run ` go test ` with the ` -nocolor ` flag,
35+ or with the env var [ ` NO_COLOR ` (with any value)] ( https://no-color.org ) .
3536
3637```
3738go test -nocolor
3839```
3940
4041```
41- IS_NO_COLOR=true go test
42+ NO_COLOR=1 go test
4243```
Original file line number Diff line number Diff line change 2222// the helper methods:
2323//
2424// func Test(t *testing.T) {
25- //
2625// // always start tests with this
2726// is := is.New(t)
2827//
3231//
3332// body := readBody(r)
3433// is.True(strings.Contains(body, "Hi there"))
35- //
3634// }
3735package is
3836
@@ -45,6 +43,7 @@ import (
4543 "os"
4644 "path/filepath"
4745 "reflect"
46+ "strconv"
4847 "strings"
4948)
5049
@@ -74,7 +73,19 @@ type I struct {
7473var noColorFlag bool
7574
7675func init () {
77- envNoColor := os .Getenv ("IS_NO_COLOR" ) == "true"
76+ var envNoColor bool
77+
78+ // prefer https://no-color.org (with any value)
79+ if _ , ok := os .LookupEnv ("NO_COLOR" ); ok {
80+ envNoColor = true
81+ }
82+
83+ if v , ok := os .LookupEnv ("IS_NO_COLOR" ); ok {
84+ if b , err := strconv .ParseBool (v ); err == nil {
85+ envNoColor = b
86+ }
87+ }
88+
7889 flag .BoolVar (& noColorFlag , "nocolor" , envNoColor , "turns off colors" )
7990}
8091
You can’t perform that action at this time.
0 commit comments