From 6541a0a9fd818424688003c617e4a84c3cf7d34d Mon Sep 17 00:00:00 2001 From: David Sherret Date: Fri, 9 Dec 2022 09:40:48 -0500 Subject: refactor: cleanup main.rs (#16996) 1. Extracts out some code from main.rs 2. Inlines all the `x_command` functions in main.rs --- cli/proc_state.rs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'cli/proc_state.rs') diff --git a/cli/proc_state.rs b/cli/proc_state.rs index 07f8a0860..5be3ae62e 100644 --- a/cli/proc_state.rs +++ b/cli/proc_state.rs @@ -41,6 +41,7 @@ use deno_core::error::AnyError; use deno_core::futures; use deno_core::parking_lot::Mutex; use deno_core::parking_lot::RwLock; +use deno_core::resolve_url_or_path; use deno_core::url::Url; use deno_core::CompiledWasmModuleStore; use deno_core::ModuleSpecifier; @@ -469,6 +470,30 @@ impl ProcState { Ok(()) } + /// Helper around prepare_module_load that loads and type checks + /// the provided files. + pub async fn load_and_type_check_files( + &self, + files: &[String], + ) -> Result<(), AnyError> { + let lib = self.options.ts_type_lib_window(); + + let specifiers = files + .iter() + .map(|file| resolve_url_or_path(file)) + .collect::, _>>()?; + self + .prepare_module_load( + specifiers, + false, + lib, + Permissions::allow_all(), + Permissions::allow_all(), + false, + ) + .await + } + /// Add the builtin node modules to the graph data. pub async fn prepare_node_std_graph(&self) -> Result<(), AnyError> { if self.node_std_graph_prepared.load(Ordering::Relaxed) { -- cgit v1.2.3