fix: ensure no ansi sequences are printed for --color=false (#2584)

This commit is contained in:
Timothy Rule
2026-01-18 13:18:52 +01:00
committed by GitHub
parent e47f55783e
commit b9c1ab8eae

View File

@@ -42,6 +42,12 @@ type (
PrintFunc func(io.Writer, string, ...any)
)
func None() PrintFunc {
c := color.New()
c.DisableColor()
return c.FprintfFunc()
}
func Default() PrintFunc {
return color.New(attrsReset...).FprintfFunc()
}
@@ -144,7 +150,7 @@ func (l *Logger) FOutf(w io.Writer, color Color, s string, args ...any) {
s, args = "%s", []any{s}
}
if !l.Color {
color = Default
color = None
}
print := color()
print(w, s, args...)
@@ -163,7 +169,7 @@ func (l *Logger) Errf(color Color, s string, args ...any) {
s, args = "%s", []any{s}
}
if !l.Color {
color = Default
color = None
}
print := color()
print(l.Stderr, s, args...)