fix(runtime): output to stderr with colors if a tty and stdout is piped (#23813)

This also fixes a bug where Deno would output to stderr with colours
when piped and stdout was not piped.
This commit is contained in:
David Sherret 2024-05-14 17:32:09 -04:00 committed by GitHub
parent 1e2b0a2219
commit e39b94f3aa
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 61 additions and 33 deletions

View file

@ -16,7 +16,8 @@ deno_core::extension!(
op_bootstrap_language,
op_bootstrap_log_level,
op_bootstrap_no_color,
op_bootstrap_is_tty,
op_bootstrap_is_stdout_tty,
op_bootstrap_is_stderr_tty,
op_bootstrap_unstable_args,
op_snapshot_options,
],
@ -117,7 +118,13 @@ pub fn op_bootstrap_no_color(state: &mut OpState) -> bool {
}
#[op2(fast)]
pub fn op_bootstrap_is_tty(state: &mut OpState) -> bool {
pub fn op_bootstrap_is_stdout_tty(state: &mut OpState) -> bool {
let options = state.borrow::<BootstrapOptions>();
options.is_tty
options.is_stdout_tty
}
#[op2(fast)]
pub fn op_bootstrap_is_stderr_tty(state: &mut OpState) -> bool {
let options = state.borrow::<BootstrapOptions>();
options.is_stderr_tty
}