From e204677ff8da6443b7ad8996a88b527e5e4de65e Mon Sep 17 00:00:00 2001 From: Mike Farah Date: Sat, 7 Dec 2024 16:03:00 +1100 Subject: [PATCH] Fixed no-colors regression #2218 --- cmd/root.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cmd/root.go b/cmd/root.go index 80ebe8e122..8af5622b8c 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -71,6 +71,10 @@ yq -P -oy sample.json level := logging.WARNING stringFormat := `[%{level}] %{color}%{time:15:04:05}%{color:reset} %{message}` + // when NO_COLOR environment variable presents and not an empty string the coloured output should be disabled; + // refer to no-color.org + forceNoColor = forceNoColor || os.Getenv("NO_COLOR") != "" + if verbose && forceNoColor { level = logging.DEBUG stringFormat = `[%{level:5.5s}] %{time:15:04:05} %{shortfile:-33s} %{shortfunc:-25s} %{message}` @@ -90,10 +94,6 @@ yq -P -oy sample.json logging.SetBackend(backend) yqlib.InitExpressionParser() - // when NO_COLOR environment variable presents and not an empty string the coloured output should be disabled; - // refer to no-color.org - forceNoColor = os.Getenv("NO_COLOR") != "" - return nil }, }