diff options
Diffstat (limited to 'cli/tools')
-rw-r--r-- | cli/tools/installer.rs | 21 | ||||
-rw-r--r-- | cli/tools/upgrade.rs | 6 |
2 files changed, 12 insertions, 15 deletions
diff --git a/cli/tools/installer.rs b/cli/tools/installer.rs index 252939f85..c32423f71 100644 --- a/cli/tools/installer.rs +++ b/cli/tools/installer.rs @@ -8,6 +8,7 @@ use deno_core::error::AnyError; use deno_core::resolve_url_or_path; use deno_core::url::Url; use log::Level; +use once_cell::sync::Lazy; use regex::Regex; use regex::RegexBuilder; use std::env; @@ -21,15 +22,12 @@ use std::path::PathBuf; #[cfg(not(windows))] use std::os::unix::fs::PermissionsExt; -lazy_static::lazy_static! { - static ref EXEC_NAME_RE: Regex = RegexBuilder::new( - r"^[a-z][\w-]*$" - ).case_insensitive(true).build().unwrap(); - // Regular expression to test disk driver letter. eg "C:\\User\username\path\to" - static ref DRIVE_LETTER_REG: Regex = RegexBuilder::new( - r"^[c-z]:" - ).case_insensitive(true).build().unwrap(); -} +static EXEC_NAME_RE: Lazy<Regex> = Lazy::new(|| { + RegexBuilder::new(r"^[a-z][\w-]*$") + .case_insensitive(true) + .build() + .unwrap() +}); fn validate_name(exec_name: &str) -> Result<(), AnyError> { if EXEC_NAME_RE.is_match(exec_name) { @@ -375,13 +373,12 @@ fn is_in_path(dir: &Path) -> bool { mod tests { use super::*; use deno_core::parking_lot::Mutex; + use once_cell::sync::Lazy; use std::process::Command; use tempfile::TempDir; use test_util::testdata_path; - lazy_static::lazy_static! { - pub static ref ENV_LOCK: Mutex<()> = Mutex::new(()); - } + pub static ENV_LOCK: Lazy<Mutex<()>> = Lazy::new(|| Mutex::new(())); #[test] fn install_infer_name_from_url() { diff --git a/cli/tools/upgrade.rs b/cli/tools/upgrade.rs index 5838cb290..b0fddc39c 100644 --- a/cli/tools/upgrade.rs +++ b/cli/tools/upgrade.rs @@ -7,6 +7,7 @@ use deno_core::error::AnyError; use deno_core::futures::StreamExt; use deno_runtime::deno_fetch::reqwest; use deno_runtime::deno_fetch::reqwest::Client; +use once_cell::sync::Lazy; use semver_parser::version::parse as semver_parse; use std::fs; use std::io::Write; @@ -15,9 +16,8 @@ use std::path::PathBuf; use std::process::Command; use tempfile::TempDir; -lazy_static::lazy_static! { - static ref ARCHIVE_NAME: String = format!("deno-{}.zip", env!("TARGET")); -} +static ARCHIVE_NAME: Lazy<String> = + Lazy::new(|| format!("deno-{}.zip", env!("TARGET"))); const RELEASE_URL: &str = "https://github.com/denoland/deno/releases"; |