From e39b94f3aa09bc77280b98caebb9ae472f8f6c5a Mon Sep 17 00:00:00 2001 From: David Sherret Date: Tue, 14 May 2024 17:32:09 -0400 Subject: 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. --- runtime/ops/bootstrap.rs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'runtime/ops/bootstrap.rs') diff --git a/runtime/ops/bootstrap.rs b/runtime/ops/bootstrap.rs index cbb87db88..eb9dbc6e8 100644 --- a/runtime/ops/bootstrap.rs +++ b/runtime/ops/bootstrap.rs @@ -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::(); - options.is_tty + options.is_stdout_tty +} + +#[op2(fast)] +pub fn op_bootstrap_is_stderr_tty(state: &mut OpState) -> bool { + let options = state.borrow::(); + options.is_stderr_tty } -- cgit v1.2.3