From 136dce67cec749dce5989ea29e88359ef79a0045 Mon Sep 17 00:00:00 2001 From: David Sherret Date: Fri, 14 Apr 2023 16:22:33 -0400 Subject: refactor: break up `ProcState` (#18707) 1. Breaks up functionality within `ProcState` into several other structs to break out the responsibilities (`ProcState` is only a data struct now). 2. Moves towards being able to inject dependencies more easily and have functionality only require what it needs. 3. Exposes `Arc` around the "service structs" instead of it being embedded within them. The idea behind embedding them was to reduce the verbosity of needing to pass around `Arc<...>`, but I don't think it was exactly working and as we move more of these structs to be more injectable I don't think the extra verbosity will be a big deal. --- cli/npm/resolvers/common.rs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'cli/npm/resolvers/common.rs') diff --git a/cli/npm/resolvers/common.rs b/cli/npm/resolvers/common.rs index 8b8be5ce2..a31459a70 100644 --- a/cli/npm/resolvers/common.rs +++ b/cli/npm/resolvers/common.rs @@ -3,6 +3,7 @@ use std::io::ErrorKind; use std::path::Path; use std::path::PathBuf; +use std::sync::Arc; use async_trait::async_trait; use deno_ast::ModuleSpecifier; @@ -26,11 +27,10 @@ pub trait NpmPackageFsResolver: Send + Sync { /// The local node_modules folder if it is applicable to the implementation. fn node_modules_path(&self) -> Option; - fn resolve_package_folder_from_deno_module( + fn package_folder( &self, - id: &NpmPackageId, + package_id: &NpmPackageId, ) -> Result; - fn resolve_package_folder_from_package( &self, name: &str, @@ -43,8 +43,6 @@ pub trait NpmPackageFsResolver: Send + Sync { specifier: &ModuleSpecifier, ) -> Result; - fn package_size(&self, package_id: &NpmPackageId) -> Result; - async fn cache_packages(&self) -> Result<(), AnyError>; fn ensure_read_permission( @@ -57,7 +55,7 @@ pub trait NpmPackageFsResolver: Send + Sync { /// Caches all the packages in parallel. pub async fn cache_packages( mut packages: Vec, - cache: &NpmCache, + cache: &Arc, registry_url: &Url, ) -> Result<(), AnyError> { let sync_download = should_sync_download(); -- cgit v1.2.3