diff options
author | David Sherret <dsherret@users.noreply.github.com> | 2023-04-14 16:22:33 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-14 16:22:33 -0400 |
commit | 136dce67cec749dce5989ea29e88359ef79a0045 (patch) | |
tree | 38e96bbbf22dc06cdba418a35467b215f1335549 /cli/npm/resolvers/common.rs | |
parent | a4111442191fff300132259752e6d2d5613d1871 (diff) |
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<T>` 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.
Diffstat (limited to 'cli/npm/resolvers/common.rs')
-rw-r--r-- | cli/npm/resolvers/common.rs | 10 |
1 files changed, 4 insertions, 6 deletions
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<PathBuf>; - fn resolve_package_folder_from_deno_module( + fn package_folder( &self, - id: &NpmPackageId, + package_id: &NpmPackageId, ) -> Result<PathBuf, AnyError>; - fn resolve_package_folder_from_package( &self, name: &str, @@ -43,8 +43,6 @@ pub trait NpmPackageFsResolver: Send + Sync { specifier: &ModuleSpecifier, ) -> Result<PathBuf, AnyError>; - fn package_size(&self, package_id: &NpmPackageId) -> Result<u64, AnyError>; - 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<NpmResolutionPackage>, - cache: &NpmCache, + cache: &Arc<NpmCache>, registry_url: &Url, ) -> Result<(), AnyError> { let sync_download = should_sync_download(); |