diff options
author | David Sherret <dsherret@users.noreply.github.com> | 2022-12-09 09:40:48 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-12-09 09:40:48 -0500 |
commit | 6541a0a9fd818424688003c617e4a84c3cf7d34d (patch) | |
tree | 0a2281e9f119bb992fe34908665a79f5eaddaa77 /cli/proc_state.rs | |
parent | 9daf6e197a642a88d79614fb53888b5bb954463a (diff) |
refactor: cleanup main.rs (#16996)
1. Extracts out some code from main.rs
2. Inlines all the `x_command` functions in main.rs
Diffstat (limited to 'cli/proc_state.rs')
-rw-r--r-- | cli/proc_state.rs | 25 |
1 files changed, 25 insertions, 0 deletions
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::<Result<Vec<_>, _>>()?; + 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) { |