summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Sherret <dsherret@users.noreply.github.com>2024-02-07 11:25:14 -0500
committerGitHub <noreply@github.com>2024-02-07 11:25:14 -0500
commit83d72e5c1c0b983f4b63f3f64f9a1de7600985f4 (patch)
tree49dfd980df2fce512fa13c3650d1c45a3e500a51
parenta32e7f0eb23fa17f5af2fc4c8abfd79762934244 (diff)
refactor: extract out `runtime::colors` to `deno_terminal::colors` (#22324)
-rw-r--r--Cargo.lock13
-rw-r--r--Cargo.toml1
-rw-r--r--cli/Cargo.toml1
-rw-r--r--cli/args/mod.rs2
-rw-r--r--cli/diagnostics.rs2
-rw-r--r--cli/main.rs2
-rw-r--r--cli/module_loader.rs2
-rw-r--r--cli/tools/bundle.rs2
-rw-r--r--cli/tools/check.rs2
-rw-r--r--cli/tools/compile.rs2
-rw-r--r--cli/tools/info.rs2
-rw-r--r--cli/tools/jupyter/mod.rs2
-rw-r--r--cli/tools/registry/mod.rs2
-rw-r--r--cli/tools/run/hmr.rs2
-rw-r--r--cli/tsc/diagnostics.rs2
-rw-r--r--cli/util/progress_bar/renderer.rs2
-rw-r--r--cli/worker.rs6
-rw-r--r--runtime/Cargo.toml2
-rw-r--r--runtime/colors.rs230
-rw-r--r--runtime/fmt_errors.rs8
-rw-r--r--runtime/lib.rs1
-rw-r--r--runtime/permissions/mod.rs2
-rw-r--r--runtime/permissions/prompter.rs2
-rw-r--r--runtime/web_worker.rs2
-rw-r--r--runtime/worker_bootstrap.rs4
25 files changed, 40 insertions, 258 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 345323b58..d9ac61663 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -994,6 +994,7 @@ dependencies = [
"deno_runtime",
"deno_semver",
"deno_task_shell",
+ "deno_terminal",
"dissimilar",
"dotenvy",
"dprint-plugin-json",
@@ -1681,6 +1682,7 @@ dependencies = [
"deno_napi",
"deno_net",
"deno_node",
+ "deno_terminal",
"deno_tls",
"deno_url",
"deno_web",
@@ -1712,7 +1714,6 @@ dependencies = [
"rustyline",
"serde",
"signal-hook-registry",
- "termcolor",
"test_util",
"tokio",
"tokio-metrics",
@@ -1753,6 +1754,16 @@ dependencies = [
]
[[package]]
+name = "deno_terminal"
+version = "0.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b847702ef57565e1417fad2291f65a3c8a5ecf2ba38d64e56f02828e7546d891"
+dependencies = [
+ "once_cell",
+ "termcolor",
+]
+
+[[package]]
name = "deno_tls"
version = "0.123.0"
dependencies = [
diff --git a/Cargo.toml b/Cargo.toml
index e081f8c67..c4d2ca014 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -48,6 +48,7 @@ deno_bench_util = { version = "0.130.0", path = "./bench_util" }
deno_lockfile = "0.18.0"
deno_media_type = { version = "0.1.1", features = ["module_specifier"] }
deno_runtime = { version = "0.144.0", path = "./runtime" }
+deno_terminal = "0.1.0"
napi_sym = { version = "0.66.0", path = "./cli/napi/sym" }
test_util = { path = "./test_util" }
diff --git a/cli/Cargo.toml b/cli/Cargo.toml
index 145544f58..a60e56a4f 100644
--- a/cli/Cargo.toml
+++ b/cli/Cargo.toml
@@ -66,6 +66,7 @@ deno_npm = "=0.16.0"
deno_runtime = { workspace = true, features = ["include_js_files_for_snapshotting"] }
deno_semver = "=0.5.4"
deno_task_shell = "=0.14.3"
+deno_terminal.workspace = true
eszip = "=0.60.0"
napi_sym.workspace = true
diff --git a/cli/args/mod.rs b/cli/args/mod.rs
index 6af39ff45..419066fba 100644
--- a/cli/args/mod.rs
+++ b/cli/args/mod.rs
@@ -42,7 +42,6 @@ use deno_core::normalize_path;
use deno_core::parking_lot::Mutex;
use deno_core::serde_json;
use deno_core::url::Url;
-use deno_runtime::colors;
use deno_runtime::deno_node::PackageJson;
use deno_runtime::deno_tls::deno_native_certs::load_native_certs;
use deno_runtime::deno_tls::rustls;
@@ -51,6 +50,7 @@ use deno_runtime::deno_tls::rustls_pemfile;
use deno_runtime::deno_tls::webpki_roots;
use deno_runtime::inspector_server::InspectorServer;
use deno_runtime::permissions::PermissionsOptions;
+use deno_terminal::colors;
use dotenvy::from_filename;
use once_cell::sync::Lazy;
use once_cell::sync::OnceCell;
diff --git a/cli/diagnostics.rs b/cli/diagnostics.rs
index f6f68e1d0..7eff66d76 100644
--- a/cli/diagnostics.rs
+++ b/cli/diagnostics.rs
@@ -11,7 +11,7 @@ use deno_ast::SourcePos;
use deno_ast::SourceRange;
use deno_ast::SourceRanged;
use deno_ast::SourceTextInfo;
-use deno_runtime::colors;
+use deno_terminal::colors;
use unicode_width::UnicodeWidthStr;
use crate::cache::LazyGraphSourceParser;
diff --git a/cli/main.rs b/cli/main.rs
index 3f49677d8..9d0ade085 100644
--- a/cli/main.rs
+++ b/cli/main.rs
@@ -42,9 +42,9 @@ use deno_core::error::JsError;
use deno_core::futures::FutureExt;
use deno_core::unsync::JoinHandle;
use deno_npm::resolution::SnapshotFromLockfileError;
-use deno_runtime::colors;
use deno_runtime::fmt_errors::format_js_error;
use deno_runtime::tokio_util::create_and_run_current_thread_with_maybe_metrics;
+use deno_terminal::colors;
use factory::CliFactory;
use std::env;
use std::env::current_exe;
diff --git a/cli/module_loader.rs b/cli/module_loader.rs
index 0058b9be0..4b120796b 100644
--- a/cli/module_loader.rs
+++ b/cli/module_loader.rs
@@ -52,10 +52,10 @@ use deno_graph::JsonModule;
use deno_graph::Module;
use deno_graph::Resolution;
use deno_lockfile::Lockfile;
-use deno_runtime::colors;
use deno_runtime::deno_fs;
use deno_runtime::permissions::PermissionsContainer;
use deno_semver::npm::NpmPackageReqReference;
+use deno_terminal::colors;
use std::borrow::Cow;
use std::collections::HashSet;
use std::pin::Pin;
diff --git a/cli/tools/bundle.rs b/cli/tools/bundle.rs
index 33ec78fc9..4099ad41a 100644
--- a/cli/tools/bundle.rs
+++ b/cli/tools/bundle.rs
@@ -4,7 +4,7 @@ use std::path::PathBuf;
use deno_core::error::AnyError;
use deno_graph::Module;
-use deno_runtime::colors;
+use deno_terminal::colors;
use crate::args::BundleFlags;
use crate::args::CliOptions;
diff --git a/cli/tools/check.rs b/cli/tools/check.rs
index 90a1d0299..6e14d09f5 100644
--- a/cli/tools/check.rs
+++ b/cli/tools/check.rs
@@ -9,8 +9,8 @@ use deno_ast::ModuleSpecifier;
use deno_core::error::AnyError;
use deno_graph::Module;
use deno_graph::ModuleGraph;
-use deno_runtime::colors;
use deno_runtime::deno_node::NodeResolver;
+use deno_terminal::colors;
use once_cell::sync::Lazy;
use regex::Regex;
diff --git a/cli/tools/compile.rs b/cli/tools/compile.rs
index a97ddcdf8..70baed669 100644
--- a/cli/tools/compile.rs
+++ b/cli/tools/compile.rs
@@ -11,7 +11,7 @@ use deno_core::error::generic_error;
use deno_core::error::AnyError;
use deno_core::resolve_url_or_path;
use deno_graph::GraphKind;
-use deno_runtime::colors;
+use deno_terminal::colors;
use std::path::Path;
use std::path::PathBuf;
use std::sync::Arc;
diff --git a/cli/tools/info.rs b/cli/tools/info.rs
index a9d6a8c59..30ceb98e4 100644
--- a/cli/tools/info.rs
+++ b/cli/tools/info.rs
@@ -20,10 +20,10 @@ use deno_graph::Resolution;
use deno_npm::resolution::NpmResolutionSnapshot;
use deno_npm::NpmPackageId;
use deno_npm::NpmResolutionPackage;
-use deno_runtime::colors;
use deno_semver::npm::NpmPackageNvReference;
use deno_semver::npm::NpmPackageReqReference;
use deno_semver::package::PackageNv;
+use deno_terminal::colors;
use crate::args::Flags;
use crate::args::InfoFlags;
diff --git a/cli/tools/jupyter/mod.rs b/cli/tools/jupyter/mod.rs
index c74b29586..ea58328bb 100644
--- a/cli/tools/jupyter/mod.rs
+++ b/cli/tools/jupyter/mod.rs
@@ -13,11 +13,11 @@ use deno_core::located_script_name;
use deno_core::resolve_url_or_path;
use deno_core::serde::Deserialize;
use deno_core::serde_json;
-use deno_runtime::colors;
use deno_runtime::deno_io::Stdio;
use deno_runtime::deno_io::StdioPipe;
use deno_runtime::permissions::Permissions;
use deno_runtime::permissions::PermissionsContainer;
+use deno_terminal::colors;
use tokio::sync::mpsc;
use tokio::sync::mpsc::unbounded_channel;
use tokio::sync::mpsc::UnboundedSender;
diff --git a/cli/tools/registry/mod.rs b/cli/tools/registry/mod.rs
index 22f53dab4..5f03fa6fd 100644
--- a/cli/tools/registry/mod.rs
+++ b/cli/tools/registry/mod.rs
@@ -15,8 +15,8 @@ use deno_core::futures::FutureExt;
use deno_core::serde_json;
use deno_core::serde_json::json;
use deno_core::unsync::JoinSet;
-use deno_runtime::colors;
use deno_runtime::deno_fetch::reqwest;
+use deno_terminal::colors;
use import_map::ImportMap;
use lsp_types::Url;
use serde::Serialize;
diff --git a/cli/tools/run/hmr.rs b/cli/tools/run/hmr.rs
index bfed22d07..88f90f680 100644
--- a/cli/tools/run/hmr.rs
+++ b/cli/tools/run/hmr.rs
@@ -11,7 +11,7 @@ use deno_core::serde_json::json;
use deno_core::serde_json::{self};
use deno_core::url::Url;
use deno_core::LocalInspectorSession;
-use deno_runtime::colors;
+use deno_terminal::colors;
use std::collections::HashMap;
use std::path::PathBuf;
use std::sync::Arc;
diff --git a/cli/tsc/diagnostics.rs b/cli/tsc/diagnostics.rs
index 2030b5ba2..362385c07 100644
--- a/cli/tsc/diagnostics.rs
+++ b/cli/tsc/diagnostics.rs
@@ -2,7 +2,7 @@
use deno_ast::ModuleSpecifier;
use deno_graph::ModuleGraph;
-use deno_runtime::colors;
+use deno_terminal::colors;
use deno_core::serde::Deserialize;
use deno_core::serde::Deserializer;
diff --git a/cli/util/progress_bar/renderer.rs b/cli/util/progress_bar/renderer.rs
index aed4c54b9..a8eb07636 100644
--- a/cli/util/progress_bar/renderer.rs
+++ b/cli/util/progress_bar/renderer.rs
@@ -2,7 +2,7 @@
use std::time::Duration;
-use deno_runtime::colors;
+use deno_terminal::colors;
use crate::util::display::human_download_size;
diff --git a/cli/worker.rs b/cli/worker.rs
index 4423f3228..e5a750597 100644
--- a/cli/worker.rs
+++ b/cli/worker.rs
@@ -23,7 +23,6 @@ use deno_core::PollEventLoopOptions;
use deno_core::SharedArrayBufferStore;
use deno_core::SourceMapGetter;
use deno_lockfile::Lockfile;
-use deno_runtime::colors;
use deno_runtime::deno_broadcast_channel::InMemoryBroadcastChannel;
use deno_runtime::deno_fs;
use deno_runtime::deno_node;
@@ -44,6 +43,7 @@ use deno_runtime::BootstrapOptions;
use deno_runtime::WorkerLogLevel;
use deno_semver::npm::NpmPackageReqReference;
use deno_semver::package::PackageReqReference;
+use deno_terminal::colors;
use tokio::select;
use crate::args::package_json::PackageJsonDeps;
@@ -583,7 +583,7 @@ impl CliMainWorkerFactory {
locale: deno_core::v8::icu::get_language_tag(),
location: shared.options.location.clone(),
no_color: !colors::use_color(),
- is_tty: colors::is_tty(),
+ is_tty: deno_terminal::is_stdout_tty(),
unstable: shared.options.unstable,
unstable_features,
user_agent: version::get_user_agent().to_string(),
@@ -789,7 +789,7 @@ fn create_web_worker_callback(
locale: deno_core::v8::icu::get_language_tag(),
location: Some(args.main_module.clone()),
no_color: !colors::use_color(),
- is_tty: colors::is_tty(),
+ is_tty: deno_terminal::is_stdout_tty(),
unstable: shared.options.unstable,
unstable_features,
user_agent: version::get_user_agent().to_string(),
diff --git a/runtime/Cargo.toml b/runtime/Cargo.toml
index 083d8005f..1c897b938 100644
--- a/runtime/Cargo.toml
+++ b/runtime/Cargo.toml
@@ -90,6 +90,7 @@ deno_kv.workspace = true
deno_napi.workspace = true
deno_net.workspace = true
deno_node.workspace = true
+deno_terminal.workspace = true
deno_tls.workspace = true
deno_url.workspace = true
deno_web.workspace = true
@@ -119,7 +120,6 @@ ring.workspace = true
rustyline = { workspace = true, features = ["custom-bindings"] }
serde.workspace = true
signal-hook-registry = "1.4.0"
-termcolor = "1.1.3"
tokio.workspace = true
tokio-metrics.workspace = true
uuid.workspace = true
diff --git a/runtime/colors.rs b/runtime/colors.rs
deleted file mode 100644
index ff9ee24db..000000000
--- a/runtime/colors.rs
+++ /dev/null
@@ -1,230 +0,0 @@
-// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
-
-use once_cell::sync::Lazy;
-use std::fmt;
-use std::fmt::Write as _;
-use std::io::IsTerminal;
-use termcolor::Ansi;
-use termcolor::Color::Ansi256;
-use termcolor::Color::Black;
-use termcolor::Color::Blue;
-use termcolor::Color::Cyan;
-use termcolor::Color::Green;
-use termcolor::Color::Magenta;
-use termcolor::Color::Red;
-use termcolor::Color::White;
-use termcolor::Color::Yellow;
-use termcolor::ColorSpec;
-use termcolor::WriteColor;
-
-#[cfg(windows)]
-use termcolor::BufferWriter;
-#[cfg(windows)]
-use termcolor::ColorChoice;
-
-static NO_COLOR: Lazy<bool> = Lazy::new(|| {
- std::env::var_os("NO_COLOR")
- .map(|v| !v.is_empty())
- .unwrap_or(false)
-});
-
-static IS_TTY: Lazy<bool> = Lazy::new(|| std::io::stdout().is_terminal());
-
-pub fn is_tty() -> bool {
- *IS_TTY
-}
-
-pub fn use_color() -> bool {
- !(*NO_COLOR)
-}
-
-#[cfg(windows)]
-pub fn enable_ansi() {
- BufferWriter::stdout(ColorChoice::AlwaysAnsi);
-}
-
-/// A struct that can adapt a `fmt::Write` to a `std::io::Write`. If anything
-/// that can not be represented as UTF-8 is written to this writer, it will
-/// return an error.
-struct StdFmtStdIoWriter<'a>(&'a mut dyn fmt::Write);
-
-impl std::io::Write for StdFmtStdIoWriter<'_> {
- fn write(&mut self, buf: &[u8]) -> std::io::Result<usize> {
- let str = std::str::from_utf8(buf).map_err(|_| {
- std::io::Error::new(
- std::io::ErrorKind::Other,
- "failed to convert bytes to str",
- )
- })?;
- match self.0.write_str(str) {
- Ok(_) => Ok(buf.len()),
- Err(_) => Err(std::io::Error::new(
- std::io::ErrorKind::Other,
- "failed to write to fmt::Write",
- )),
- }
- }
-
- fn flush(&mut self) -> std::io::Result<()> {
- Ok(())
- }
-}
-
-/// A struct that can adapt a `std::io::Write` to a `fmt::Write`.
-struct StdIoStdFmtWriter<'a>(&'a mut dyn std::io::Write);
-
-impl fmt::Write for StdIoStdFmtWriter<'_> {
- fn write_str(&mut self, s: &str) -> fmt::Result {
- self.0.write_all(s.as_bytes()).map_err(|_| fmt::Error)?;
- Ok(())
- }
-}
-
-pub struct Style<I: fmt::Display> {
- colorspec: ColorSpec,
- inner: I,
-}
-
-impl<I: fmt::Display> fmt::Display for Style<I> {
- fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
- if !use_color() {
- return fmt::Display::fmt(&self.inner, f);
- }
- let mut ansi_writer = Ansi::new(StdFmtStdIoWriter(f));
- ansi_writer
- .set_color(&self.colorspec)
- .map_err(|_| fmt::Error)?;
- write!(StdIoStdFmtWriter(&mut ansi_writer), "{}", self.inner)?;
- ansi_writer.reset().map_err(|_| fmt::Error)?;
- Ok(())
- }
-}
-
-#[inline]
-fn style<'a, S: fmt::Display + 'a>(s: S, colorspec: ColorSpec) -> Style<S> {
- Style {
- colorspec,
- inner: s,
- }
-}
-
-pub fn red_bold<'a, S: fmt::Display + 'a>(s: S) -> Style<S> {
- let mut style_spec = ColorSpec::new();
- style_spec.set_fg(Some(Red)).set_bold(true);
- style(s, style_spec)
-}
-
-pub fn green_bold<'a, S: fmt::Display + 'a>(s: S) -> Style<S> {
- let mut style_spec = ColorSpec::new();
- style_spec.set_fg(Some(Green)).set_bold(true);
- style(s, style_spec)
-}
-
-pub fn yellow_bold<'a, S: fmt::Display + 'a>(s: S) -> Style<S> {
- let mut style_spec = ColorSpec::new();
- style_spec.set_fg(Some(Yellow)).set_bold(true);
- style(s, style_spec)
-}
-
-pub fn italic<'a, S: fmt::Display + 'a>(s: S) -> Style<S> {
- let mut style_spec = ColorSpec::new();
- style_spec.set_italic(true);
- style(s, style_spec)
-}
-
-pub fn italic_gray<'a, S: fmt::Display + 'a>(s: S) -> Style<S> {
- let mut style_spec = ColorSpec::new();
- style_spec.set_fg(Some(Ansi256(8))).set_italic(true);
- style(s, style_spec)
-}
-
-pub fn italic_bold<'a, S: fmt::Display + 'a>(s: S) -> Style<S> {
- let mut style_spec = ColorSpec::new();
- style_spec.set_bold(true).set_italic(true);
- style(s, style_spec)
-}
-
-pub fn white_on_red<'a, S: fmt::Display + 'a>(s: S) -> Style<S> {
- let mut style_spec = ColorSpec::new();
- style_spec.set_bg(Some(Red)).set_fg(Some(White));
- style(s, style_spec)
-}
-
-pub fn black_on_green<'a, S: fmt::Display + 'a>(s: S) -> Style<S> {
- let mut style_spec = ColorSpec::new();
- style_spec.set_bg(Some(Green)).set_fg(Some(Black));
- style(s, style_spec)
-}
-
-pub fn yellow<'a, S: fmt::Display + 'a>(s: S) -> Style<S> {
- let mut style_spec = ColorSpec::new();
- style_spec.set_fg(Some(Yellow));
- style(s, style_spec)
-}
-
-pub fn cyan<'a, S: fmt::Display + 'a>(s: S) -> Style<S> {
- let mut style_spec = ColorSpec::new();
- style_spec.set_fg(Some(Cyan));
- style(s, style_spec)
-}
-
-pub fn cyan_with_underline<'a>(
- s: impl fmt::Display + 'a,
-) -> impl fmt::Display + 'a {
- let mut style_spec = ColorSpec::new();
- style_spec.set_fg(Some(Cyan)).set_underline(true);
- style(s, style_spec)
-}
-
-pub fn cyan_bold<'a, S: fmt::Display + 'a>(s: S) -> Style<S> {
- let mut style_spec = ColorSpec::new();
- style_spec.set_fg(Some(Cyan)).set_bold(true);
- style(s, style_spec)
-}
-
-pub fn magenta<'a, S: fmt::Display + 'a>(s: S) -> Style<S> {
- let mut style_spec = ColorSpec::new();
- style_spec.set_fg(Some(Magenta));
- style(s, style_spec)
-}
-
-pub fn red<'a, S: fmt::Display + 'a>(s: S) -> Style<S> {
- let mut style_spec = ColorSpec::new();
- style_spec.set_fg(Some(Red));
- style(s, style_spec)
-}
-
-pub fn green<'a, S: fmt::Display + 'a>(s: S) -> Style<S> {
- let mut style_spec = ColorSpec::new();
- style_spec.set_fg(Some(Green));
- style(s, style_spec)
-}
-
-pub fn bold<'a, S: fmt::Display + 'a>(s: S) -> Style<S> {
- let mut style_spec = ColorSpec::new();
- style_spec.set_bold(true);
- style(s, style_spec)
-}
-
-pub fn gray<'a, S: fmt::Display + 'a>(s: S) -> Style<S> {
- let mut style_spec = ColorSpec::new();
- style_spec.set_fg(Some(Ansi256(245)));
- style(s, style_spec)
-}
-
-pub fn intense_blue<'a, S: fmt::Display + 'a>(s: S) -> Style<S> {
- let mut style_spec = ColorSpec::new();
- style_spec.set_fg(Some(Blue)).set_intense(true);
- style(s, style_spec)
-}
-
-pub fn white_bold_on_red<'a>(
- s: impl fmt::Display + 'a,
-) -> impl fmt::Display + 'a {
- let mut style_spec = ColorSpec::new();
- style_spec
- .set_bold(true)
- .set_bg(Some(Red))
- .set_fg(Some(White));
- style(s, style_spec)
-}
diff --git a/runtime/fmt_errors.rs b/runtime/fmt_errors.rs
index 6ec63c007..af7d76051 100644
--- a/runtime/fmt_errors.rs
+++ b/runtime/fmt_errors.rs
@@ -1,12 +1,12 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
//! This mod provides DenoError to unify errors across Deno.
-use crate::colors::cyan;
-use crate::colors::italic_bold;
-use crate::colors::red;
-use crate::colors::yellow;
use deno_core::error::format_file_name;
use deno_core::error::JsError;
use deno_core::error::JsStackFrame;
+use deno_terminal::colors::cyan;
+use deno_terminal::colors::italic_bold;
+use deno_terminal::colors::red;
+use deno_terminal::colors::yellow;
use std::fmt::Write as _;
#[derive(Debug, Clone)]
diff --git a/runtime/lib.rs b/runtime/lib.rs
index fd791974d..b63fd4134 100644
--- a/runtime/lib.rs
+++ b/runtime/lib.rs
@@ -24,7 +24,6 @@ pub use deno_webidl;
pub use deno_websocket;
pub use deno_webstorage;
-pub mod colors;
pub mod errors;
pub mod fmt_errors;
pub mod fs_util;
diff --git a/runtime/permissions/mod.rs b/runtime/permissions/mod.rs
index bdefe4f12..2cdbc6014 100644
--- a/runtime/permissions/mod.rs
+++ b/runtime/permissions/mod.rs
@@ -1,6 +1,5 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
-use crate::colors;
use crate::fs_util::resolve_from_cwd;
use deno_core::error::custom_error;
use deno_core::error::type_error;
@@ -15,6 +14,7 @@ use deno_core::serde_json;
use deno_core::url;
use deno_core::url::Url;
use deno_core::ModuleSpecifier;
+use deno_terminal::colors;
use log;
use once_cell::sync::Lazy;
use std::borrow::Cow;
diff --git a/runtime/permissions/prompter.rs b/runtime/permissions/prompter.rs
index 145e0a82e..f054b31f3 100644
--- a/runtime/permissions/prompter.rs
+++ b/runtime/permissions/prompter.rs
@@ -1,8 +1,8 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
-use crate::colors;
use deno_core::error::AnyError;
use deno_core::parking_lot::Mutex;
+use deno_terminal::colors;
use once_cell::sync::Lazy;
use std::fmt::Write;
use std::io::BufRead;
diff --git a/runtime/web_worker.rs b/runtime/web_worker.rs
index 78674af02..b21833a2e 100644
--- a/runtime/web_worker.rs
+++ b/runtime/web_worker.rs
@@ -1,5 +1,4 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
-use crate::colors;
use crate::inspector_server::InspectorServer;
use crate::ops;
use crate::permissions::PermissionsContainer;
@@ -45,6 +44,7 @@ use deno_fs::FileSystem;
use deno_http::DefaultHttpPropertyExtractor;
use deno_io::Stdio;
use deno_kv::dynamic::MultiBackendDbHandler;
+use deno_terminal::colors;
use deno_tls::RootCertStoreProvider;
use deno_web::create_entangled_message_port;
use deno_web::BlobStore;
diff --git a/runtime/worker_bootstrap.rs b/runtime/worker_bootstrap.rs
index 519abf74c..ca2d4d8ec 100644
--- a/runtime/worker_bootstrap.rs
+++ b/runtime/worker_bootstrap.rs
@@ -6,7 +6,7 @@ use serde::Serialize;
use std::cell::RefCell;
use std::thread;
-use crate::colors;
+use deno_terminal::colors;
/// The log level to use when printing diagnostic log messages, warnings,
/// or errors in the worker.
@@ -77,7 +77,7 @@ impl Default for BootstrapOptions {
user_agent,
cpu_count,
no_color: !colors::use_color(),
- is_tty: colors::is_tty(),
+ is_tty: deno_terminal::is_stdout_tty(),
enable_op_summary_metrics: Default::default(),
enable_testing_features: Default::default(),
log_level: Default::default(),