From 1eefe3e42b40ef8a2cd7cc4f29540aff11974165 Mon Sep 17 00:00:00 2001 From: David Sherret Date: Mon, 20 Nov 2023 15:58:22 -0500 Subject: fix: Deno.noColor should not be true when NO_COLOR is empty string (#21275) Closes https://github.com/denoland/deno/issues/21274 --- runtime/colors.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'runtime') diff --git a/runtime/colors.rs b/runtime/colors.rs index fe5a3dcbe..8d915b571 100644 --- a/runtime/colors.rs +++ b/runtime/colors.rs @@ -22,8 +22,11 @@ use termcolor::BufferWriter; #[cfg(windows)] use termcolor::ColorChoice; -static NO_COLOR: Lazy = - Lazy::new(|| std::env::var_os("NO_COLOR").is_some()); +static NO_COLOR: Lazy = Lazy::new(|| { + std::env::var_os("NO_COLOR") + .map(|v| !v.is_empty()) + .unwrap_or(false) +}); static IS_TTY: Lazy = Lazy::new(|| std::io::stdout().is_terminal()); -- cgit v1.2.3