fix(diagnostics): do not print ansi color codes in non-TTYs (#3624)

closes #3539

upstream issue https://github.com/zkat/miette/issues/380
This commit is contained in:
Boshen 2024-06-11 16:16:28 +08:00 committed by GitHub
parent f9c08d1e28
commit e6ad3fbf16
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

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