Skip to content

Commit

Permalink
Respect the NO_COLOR environment variable if it is set.
Browse files Browse the repository at this point in the history
If set, this will turn off colourization of the output.

See https://no-color.org/

Fixes #90
  • Loading branch information
asmaloney committed Jan 2, 2021
1 parent 6297c3b commit eea6cbf
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion issues/issue.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func (issue *Issue) text() string {
return issue.Message
}

// Print to stdout with colour
// Print to stdout with optional colour (controlled by color.NoColor - see main())
func (issue *Issue) print(force bool, prefix string) {
if (issue.Level < issue.store.logLevel) && !force {
return
Expand Down
7 changes: 6 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ Options:
// fmt.Println(arguments)

var options map[string]interface{}

// Check for NO_COLOR environment variable and turn off colourization if
// it is set.
// See https://no-color.org/
color.NoColor = os.Getenv("NO_COLOR") != ""

if arguments["--conf"] != nil {
// Config file specified
options = parseConfFile(arguments, arguments["--conf"].(string), true)
Expand All @@ -65,7 +71,6 @@ Options:

exitCode := run(options)
os.Exit(exitCode)

}

type optsMap map[string]interface{}
Expand Down

0 comments on commit eea6cbf

Please sign in to comment.