diff --git a/cmd/constant.go b/cmd/constant.go index eb6e9aeb..762897d0 100644 --- a/cmd/constant.go +++ b/cmd/constant.go @@ -1,7 +1,5 @@ package cmd -import "os" - var unwrapScalarFlag = newUnwrapFlag() var unwrapScalar = false @@ -26,12 +24,6 @@ var forceColor = false var forceNoColor = false var colorsEnabled = false -func init() { - // 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") != "" -} - // can be either "" (off), "extract" or "process" var frontMatter = "" diff --git a/cmd/root.go b/cmd/root.go index 450de573..80ebe8e1 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -90,6 +90,10 @@ 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 }, }