mirror of
https://github.com/go-task/task.git
synced 2026-07-07 14:09:11 +00: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)
|
PrintFunc func(io.Writer, string, ...any)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func None() PrintFunc {
|
||||||
|
c := color.New()
|
||||||
|
c.DisableColor()
|
||||||
|
return c.FprintfFunc()
|
||||||
|
}
|
||||||
|
|
||||||
func Default() PrintFunc {
|
func Default() PrintFunc {
|
||||||
return color.New(attrsReset...).FprintfFunc()
|
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}
|
s, args = "%s", []any{s}
|
||||||
}
|
}
|
||||||
if !l.Color {
|
if !l.Color {
|
||||||
color = Default
|
color = None
|
||||||
}
|
}
|
||||||
print := color()
|
print := color()
|
||||||
print(w, s, args...)
|
print(w, s, args...)
|
||||||
@@ -163,7 +169,7 @@ func (l *Logger) Errf(color Color, s string, args ...any) {
|
|||||||
s, args = "%s", []any{s}
|
s, args = "%s", []any{s}
|
||||||
}
|
}
|
||||||
if !l.Color {
|
if !l.Color {
|
||||||
color = Default
|
color = None
|
||||||
}
|
}
|
||||||
print := color()
|
print := color()
|
||||||
print(l.Stderr, s, args...)
|
print(l.Stderr, s, args...)
|
||||||
|
|||||||
Reference in New Issue
Block a user