Skip to content
This repository was archived by the owner on Jun 10, 2026. It is now read-only.

Commit 5923307

Browse files
committed
fix(render): make NO_COLOR authoritative for color output
1 parent ba5516c commit 5923307

3 files changed

Lines changed: 6 additions & 4 deletions

File tree

internal/render/colors.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ package render
22

33
import "os"
44

5-
var IS_COLOR_ENABLED = os.Getenv("NO_COLOR") == "" || os.Getenv("CI") != ""
5+
func IsColorEnabled() bool {
6+
return os.Getenv("NO_COLOR") == ""
7+
}
68

79
const (
810
Reset = "\033[0m"
@@ -16,7 +18,7 @@ const (
1618
)
1719

1820
func Paint(content, code string, noColor bool) string {
19-
if noColor || !IS_COLOR_ENABLED {
21+
if noColor || !IsColorEnabled() {
2022
return content
2123
}
2224

internal/render/utils.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ func Hyperlink(text, url string, noColor bool) string {
1515
}
1616

1717
func supportsHyperlinks() bool {
18-
return IS_COLOR_ENABLED &&
18+
return IsColorEnabled() &&
1919
os.Getenv("TERM") != "dumb" &&
2020
term.IsTerminal(int(os.Stdout.Fd()))
2121
}

internal/style/style.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ func printJSONToWriter(w *os.File, data any, noColor bool) error {
175175
payload += "\n"
176176
}
177177

178-
if noColor || !render.IS_COLOR_ENABLED {
178+
if noColor || !render.IsColorEnabled() {
179179
_, err = fmt.Fprint(w, payload)
180180
return err
181181
}

0 commit comments

Comments
 (0)