Skip to content

Commit

Permalink
Enable color outputting when NO_COLOR is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
acuteenvy committed Nov 4, 2023
1 parent afae118 commit 52210fe
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,13 @@ pub fn init_color(color_mode: ColorChoice) {
#[cfg(not(target_os = "windows"))]
let color_support = true;

let no_color = env::var_os("NO_COLOR").is_some_and(|x| !x.is_empty());

match color_mode {
ColorChoice::Always => {}
ColorChoice::Never => Paint::disable(),
ColorChoice::Auto => {
if !(color_support && env::var_os("NO_COLOR").is_none() && io::stdout().is_terminal()) {
if !(color_support && !no_color && io::stdout().is_terminal()) {
Paint::disable();
}
}
Expand Down

0 comments on commit 52210fe

Please sign in to comment.