Skip to content

Commit

Permalink
Merge pull request #243 from dnephin/enable-color-on-github-actions
Browse files Browse the repository at this point in the history
Enable color by default when run from github actions
  • Loading branch information
dnephin committed Apr 9, 2022
2 parents a8b4e27 + 9e8433c commit 69fcbcb
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 69fcbcb

Please sign in to comment.