Skip to content

Commit 69fcbcb

Browse files
authored
Merge pull request #243 from dnephin/enable-color-on-github-actions
Enable color by default when run from github actions
2 parents a8b4e27 + 9e8433c commit 69fcbcb

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

cmd/main.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ func setupFlags(name string) (*pflag.FlagSet, *options) {
6767
flags.StringVar(&opts.jsonFile, "jsonfile",
6868
lookEnvWithDefault("GOTESTSUM_JSONFILE", ""),
6969
"write all TestEvents to file")
70-
flags.BoolVar(&opts.noColor, "no-color", color.NoColor, "disable color output")
70+
flags.BoolVar(&opts.noColor, "no-color", defaultNoColor, "disable color output")
7171

7272
flags.Var(opts.hideSummary, "no-summary",
7373
"do not print summary of: "+testjson.SummarizeAll.String())
@@ -175,6 +175,13 @@ func (o options) Validate() error {
175175
return nil
176176
}
177177

178+
var defaultNoColor = func() bool {
179+
if os.Getenv("GITHUB_ACTIONS") == "true" {
180+
return false
181+
}
182+
return color.NoColor
183+
}()
184+
178185
func setupLogging(opts *options) {
179186
if opts.debug {
180187
log.SetLevel(log.DebugLevel)

0 commit comments

Comments
 (0)