diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2023-12-12 15:45:20 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-12 23:45:20 +0900 |
commit | 06c5f99a01698feba4ce67fa911428cf2d8c95d4 (patch) | |
tree | ee9b098bc7eb6ae95687916c8b2d9483732700e5 /cli/cache/mod.rs | |
parent | 93ea46b31d7dc13354fc16308f73163375de6af7 (diff) |
refactor: better handling for registry urls (#21545)
Diffstat (limited to 'cli/cache/mod.rs')
-rw-r--r-- | cli/cache/mod.rs | 22 |
1 files changed, 2 insertions, 20 deletions
diff --git a/cli/cache/mod.rs b/cli/cache/mod.rs index 81c126098..214e2a3dc 100644 --- a/cli/cache/mod.rs +++ b/cli/cache/mod.rs @@ -1,5 +1,6 @@ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. +use crate::args::deno_registry_url; use crate::args::CacheSetting; use crate::errors::get_error_class_name; use crate::file_fetcher::FetchOptions; @@ -17,7 +18,6 @@ use deno_graph::source::LoadFuture; use deno_graph::source::LoadResponse; use deno_graph::source::Loader; use deno_runtime::permissions::PermissionsContainer; -use once_cell::sync::Lazy; use std::collections::HashMap; use std::path::Path; use std::path::PathBuf; @@ -165,27 +165,9 @@ impl FetchCacher { } } -pub(crate) static DENO_REGISTRY_URL: Lazy<Url> = Lazy::new(|| { - let env_var_name = "DENO_REGISTRY_URL"; - if let Ok(registry_url) = std::env::var(env_var_name) { - // ensure there is a trailing slash for the directory - let registry_url = format!("{}/", registry_url.trim_end_matches('/')); - match Url::parse(®istry_url) { - Ok(url) => { - return url; - } - Err(err) => { - log::debug!("Invalid {} environment variable: {:#}", env_var_name, err,); - } - } - } - - deno_graph::source::DEFAULT_DENO_REGISTRY_URL.clone() -}); - impl Loader for FetchCacher { fn registry_url(&self) -> &Url { - &DENO_REGISTRY_URL + deno_registry_url() } fn get_cache_info(&self, specifier: &ModuleSpecifier) -> Option<CacheInfo> { |