mirror of
https://github.com/go-task/task.git
synced 2026-02-24 03:59:52 +01:00
fix: ensure no ansi sequences are printed for --color=false (#2584)
This commit is contained in:
@@ -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...)
|
||||
|
||||
Reference in New Issue
Block a user