diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2022-08-22 17:35:04 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-22 17:35:04 +0200 |
commit | c66386dbd20b735161017a239c6af013da1f1718 (patch) | |
tree | 312e4cc304901212c9d6fb95521e3e3799598531 /cli/npm/mod.rs | |
parent | 57d48134d168cc128f075cb7381d773ea028c81e (diff) |
feat(unstable): Respect --cached-only flags for npm: specifiers (#15512)
This commit changes "npm:" specifier handling to respect "--cached-only" flags and adds "Download" messages for npm registry api calls.
Co-authored-by: David Sherret <dsherret@gmail.com>
Diffstat (limited to 'cli/npm/mod.rs')
-rw-r--r-- | cli/npm/mod.rs | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/cli/npm/mod.rs b/cli/npm/mod.rs index 810cee645..16796b18a 100644 --- a/cli/npm/mod.rs +++ b/cli/npm/mod.rs @@ -29,6 +29,7 @@ use registry::NpmRegistryApi; use resolution::NpmResolution; use crate::deno_dir::DenoDir; +use crate::file_fetcher::CacheSetting; use self::cache::ReadonlyNpmCache; use self::resolution::NpmResolutionSnapshot; @@ -77,12 +78,24 @@ pub struct GlobalNpmPackageResolver { } impl GlobalNpmPackageResolver { - pub fn from_deno_dir(dir: &DenoDir, reload: bool) -> Result<Self, AnyError> { - Ok(Self::from_cache(NpmCache::from_deno_dir(dir)?, reload)) + pub fn from_deno_dir( + dir: &DenoDir, + reload: bool, + cache_setting: CacheSetting, + ) -> Result<Self, AnyError> { + Ok(Self::from_cache( + NpmCache::from_deno_dir(dir, cache_setting.clone())?, + reload, + cache_setting, + )) } - fn from_cache(cache: NpmCache, reload: bool) -> Self { - let api = NpmRegistryApi::new(cache.clone(), reload); + fn from_cache( + cache: NpmCache, + reload: bool, + cache_setting: CacheSetting, + ) -> Self { + let api = NpmRegistryApi::new(cache.clone(), reload, cache_setting); let registry_url = api.base_url().to_owned(); let resolution = Arc::new(NpmResolution::new(api)); |