fix(color): setting NO_COLOR should not print ansi codes for non-terminals (#381)

Fixes: https://github.com/zkat/miette/issues/380
This commit is contained in:
Boshen 2024-06-12 00:18:24 +08:00 committed by GitHub
parent b82cc81b8e
commit 813232ba79
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 1 additions and 1 deletions

View File

@ -71,7 +71,7 @@ impl Default for GraphicalTheme {
fn default() -> Self { fn default() -> Self {
match std::env::var("NO_COLOR") { match std::env::var("NO_COLOR") {
_ if !std::io::stdout().is_terminal() || !std::io::stderr().is_terminal() => { _ if !std::io::stdout().is_terminal() || !std::io::stderr().is_terminal() => {
Self::ascii() Self::none()
} }
Ok(string) if string != "0" => Self::unicode_nocolor(), Ok(string) if string != "0" => Self::unicode_nocolor(),
_ => Self::unicode(), _ => Self::unicode(),