diff options
Diffstat (limited to 'runtime')
-rw-r--r-- | runtime/js/99_main.js | 16 | ||||
-rw-r--r-- | runtime/ops/bootstrap.rs | 13 | ||||
-rw-r--r-- | runtime/worker_bootstrap.rs | 6 |
3 files changed, 24 insertions, 11 deletions
diff --git a/runtime/js/99_main.js b/runtime/js/99_main.js index 2ea122e34..fcec6b91a 100644 --- a/runtime/js/99_main.js +++ b/runtime/js/99_main.js @@ -8,7 +8,8 @@ import { core, internals, primordials } from "ext:core/mod.js"; const ops = core.ops; import { op_bootstrap_args, - op_bootstrap_is_tty, + op_bootstrap_is_stderr_tty, + op_bootstrap_is_stdout_tty, op_bootstrap_no_color, op_bootstrap_pid, op_main_module, @@ -62,10 +63,10 @@ import * as timers from "ext:deno_web/02_timers.js"; import { customInspect, getDefaultInspectOptions, - getNoColor, + getStderrNoColor, inspectArgs, quoteString, - setNoColorFn, + setNoColorFns, } from "ext:deno_console/01_console.js"; import * as performance from "ext:deno_web/15_performance.js"; import * as url from "ext:deno_url/00_url.js"; @@ -379,7 +380,10 @@ function importScripts(...urls) { const opArgs = memoizeLazy(() => op_bootstrap_args()); const opPid = memoizeLazy(() => op_bootstrap_pid()); -setNoColorFn(() => op_bootstrap_no_color() || !op_bootstrap_is_tty()); +setNoColorFns( + () => op_bootstrap_no_color() || !op_bootstrap_is_stdout_tty(), + () => op_bootstrap_no_color() || !op_bootstrap_is_stderr_tty(), +); function formatException(error) { if ( @@ -390,11 +394,11 @@ function formatException(error) { } else if (typeof error == "string") { return `Uncaught ${ inspectArgs([quoteString(error, getDefaultInspectOptions())], { - colors: !getNoColor(), + colors: !getStderrNoColor(), }) }`; } else { - return `Uncaught ${inspectArgs([error], { colors: !getNoColor() })}`; + return `Uncaught ${inspectArgs([error], { colors: !getStderrNoColor() })}`; } } 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::<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 } diff --git a/runtime/worker_bootstrap.rs b/runtime/worker_bootstrap.rs index 31cb883db..e1abf87fc 100644 --- a/runtime/worker_bootstrap.rs +++ b/runtime/worker_bootstrap.rs @@ -76,7 +76,8 @@ pub struct BootstrapOptions { pub location: Option<ModuleSpecifier>, /// Sets `Deno.noColor` in JS runtime. pub no_color: bool, - pub is_tty: bool, + pub is_stdout_tty: bool, + pub is_stderr_tty: bool, // --unstable flag, deprecated pub unstable: bool, // --unstable-* flags @@ -109,7 +110,8 @@ impl Default for BootstrapOptions { user_agent, cpu_count, no_color: !colors::use_color(), - is_tty: deno_terminal::is_stdout_tty(), + is_stdout_tty: deno_terminal::is_stdout_tty(), + is_stderr_tty: deno_terminal::is_stderr_tty(), enable_op_summary_metrics: Default::default(), enable_testing_features: Default::default(), log_level: Default::default(), |