Skip to content

Commit

Permalink
fix(cli): don't add colors for non-tty outputs (denoland#13031)
Browse files Browse the repository at this point in the history
  • Loading branch information
VishnuJin authored Dec 10, 2021
1 parent 542b71e commit 38f1630
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion runtime/colors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,14 @@ use termcolor::{Ansi, ColorSpec, WriteColor};
use termcolor::{BufferWriter, ColorChoice};

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();
}

// if the output is piped to a tty, use color
pub fn use_color() -> bool {
!(*NO_COLOR)
!(*NO_COLOR) && *IS_TTY
}

#[cfg(windows)]
Expand Down

0 comments on commit 38f1630

Please sign in to comment.