From 5481c527711782522266bfdcf2bb2b7485e2b547 Mon Sep 17 00:00:00 2001 From: Colin Adler Date: Mon, 6 Jan 2025 20:34:15 -0500 Subject: [PATCH] feat: respect `NO_COLOR` env var Closes https://github.com/coder/wush/issues/76 --- cliui/cliui.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cliui/cliui.go b/cliui/cliui.go index 8a7ae46..9baa25c 100644 --- a/cliui/cliui.go +++ b/cliui/cliui.go @@ -50,7 +50,7 @@ var ( func Color(s string) termenv.Color { colorOnce.Do(func() { color = termenv.NewOutput(os.Stdout).ColorProfile() - if flag.Lookup("test.v") != nil { + if _, exists := os.LookupEnv("NO_COLOR"); exists || flag.Lookup("test.v") != nil { // Use a consistent colorless profile in tests so that results // are deterministic. color = termenv.Ascii