Skip to content

Commit

Permalink
Enable color by default when run from github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
dnephin committed Apr 9, 2022
1 parent cc0c1a1 commit 9e8433c
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func setupFlags(name string) (*pflag.FlagSet, *options) {
flags.StringVar(&opts.jsonFile, "jsonfile",
lookEnvWithDefault("GOTESTSUM_JSONFILE", ""),
"write all TestEvents to file")
flags.BoolVar(&opts.noColor, "no-color", color.NoColor, "disable color output")
flags.BoolVar(&opts.noColor, "no-color", defaultNoColor, "disable color output")

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

var defaultNoColor = func() bool {
if os.Getenv("GITHUB_ACTIONS") == "true" {
return false
}
return color.NoColor
}()

func setupLogging(opts *options) {
if opts.debug {
log.SetLevel(log.DebugLevel)
Expand Down

0 comments on commit 9e8433c

Please sign in to comment.