mirror of
https://github.com/denoland/deno.git
synced 2025-01-05 05:49:20 -05:00
fix(cli): don't add colors for non-tty outputs (#13031)
This commit is contained in:
parent
542b71eef9
commit
38f1630223
1 changed files with 4 additions and 1 deletions
|
@ -9,11 +9,14 @@ use termcolor::{Ansi, ColorSpec, WriteColor};
|
||||||
use termcolor::{BufferWriter, ColorChoice};
|
use termcolor::{BufferWriter, ColorChoice};
|
||||||
|
|
||||||
lazy_static::lazy_static! {
|
lazy_static::lazy_static! {
|
||||||
|
// checks if the output is piped to a tty
|
||||||
|
static ref IS_TTY: bool = atty::is(atty::Stream::Stdout);
|
||||||
static ref NO_COLOR: bool = std::env::var_os("NO_COLOR").is_some();
|
static ref NO_COLOR: bool = std::env::var_os("NO_COLOR").is_some();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if the output is piped to a tty, use color
|
||||||
pub fn use_color() -> bool {
|
pub fn use_color() -> bool {
|
||||||
!(*NO_COLOR)
|
!(*NO_COLOR) && *IS_TTY
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
|
|
Loading…
Reference in a new issue