From c5dcd86850c6f534ed06fec3a1b21f3a126a39a3 Mon Sep 17 00:00:00 2001 From: Lukasz Mierzwa Date: Mon, 30 Sep 2024 16:34:05 +0100 Subject: [PATCH] Force colored output unless explicitly disabled Fixes #1106 --- cmd/pint/logger.go | 6 ++++++ docs/changelog.md | 1 + 2 files changed, 7 insertions(+) diff --git a/cmd/pint/logger.go b/cmd/pint/logger.go index 33438301..d6cebf32 100644 --- a/cmd/pint/logger.go +++ b/cmd/pint/logger.go @@ -4,6 +4,8 @@ import ( "fmt" "os" + "github.com/fatih/color" + "github.com/cloudflare/pint/internal/log" ) @@ -17,6 +19,10 @@ func initLogger(level string, noColor bool) error { if nc != "" && nc != "0" { noColor = true } + // Override fatih/color detection of when to **disable** coloring. + if !noColor { + color.NoColor = false + } log.Setup(l, noColor) diff --git a/docs/changelog.md b/docs/changelog.md index 8cf404e8..b52f9a78 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -6,6 +6,7 @@ - Improved accuracy of the [rule/duplicate](checks/rule/duplicate.md) check. - Fixed GitHub reporter trying to create pull request comments to unmodified lines - #1120. +- Fixed colored output on some environments - #1106. ## v0.65.1