diff options
Diffstat (limited to 'cli/tools/installer.rs')
-rw-r--r-- | cli/tools/installer.rs | 39 |
1 files changed, 20 insertions, 19 deletions
diff --git a/cli/tools/installer.rs b/cli/tools/installer.rs index b7b9b4d96..01ed36711 100644 --- a/cli/tools/installer.rs +++ b/cli/tools/installer.rs @@ -35,6 +35,7 @@ use std::path::PathBuf; #[cfg(not(windows))] use std::os::unix::fs::PermissionsExt; +use std::sync::Arc; static EXEC_NAME_RE: Lazy<Regex> = Lazy::new(|| { RegexBuilder::new(r"^[a-z0-9][\w-]*$") @@ -261,17 +262,17 @@ pub fn uninstall(uninstall_flags: UninstallFlags) -> Result<(), AnyError> { } async fn install_local( - flags: Flags, + flags: Arc<Flags>, maybe_add_flags: Option<AddFlags>, ) -> Result<(), AnyError> { if let Some(add_flags) = maybe_add_flags { return super::registry::add(flags, add_flags).await; } - let factory = CliFactory::from_flags(flags)?; + let factory = CliFactory::from_flags(flags); crate::module_loader::load_top_level_deps(&factory).await?; - if let Some(lockfile) = factory.cli_options().maybe_lockfile() { + if let Some(lockfile) = factory.cli_options()?.maybe_lockfile() { lockfile.write_if_changed()?; } @@ -279,7 +280,7 @@ async fn install_local( } pub async fn install_command( - flags: Flags, + flags: Arc<Flags>, install_flags: InstallFlags, ) -> Result<(), AnyError> { if !install_flags.global { @@ -297,11 +298,11 @@ pub async fn install_command( } async fn install_global( - flags: Flags, + flags: Arc<Flags>, install_flags_global: InstallFlagsGlobal, ) -> Result<(), AnyError> { // ensure the module is cached - let factory = CliFactory::from_flags(flags.clone())?; + let factory = CliFactory::from_flags(flags.clone()); factory .main_module_graph_container() .await? @@ -310,16 +311,16 @@ async fn install_global( let http_client = factory.http_client_provider(); // create the install shim - create_install_shim(http_client, flags, install_flags_global).await + create_install_shim(http_client, &flags, install_flags_global).await } async fn create_install_shim( http_client_provider: &HttpClientProvider, - flags: Flags, + flags: &Flags, install_flags_global: InstallFlagsGlobal, ) -> Result<(), AnyError> { let shim_data = - resolve_shim_data(http_client_provider, &flags, &install_flags_global) + resolve_shim_data(http_client_provider, flags, &install_flags_global) .await?; // ensure directory exists @@ -778,7 +779,7 @@ mod tests { create_install_shim( &HttpClientProvider::new(None, None), - Flags { + &Flags { unstable_config: UnstableConfig { legacy_flag_enabled: true, ..Default::default() @@ -1173,7 +1174,7 @@ mod tests { create_install_shim( &HttpClientProvider::new(None, None), - Flags::default(), + &Flags::default(), InstallFlagsGlobal { module_url: local_module_str.to_string(), args: vec![], @@ -1203,7 +1204,7 @@ mod tests { create_install_shim( &HttpClientProvider::new(None, None), - Flags::default(), + &Flags::default(), InstallFlagsGlobal { module_url: "http://localhost:4545/echo_server.ts".to_string(), args: vec![], @@ -1224,7 +1225,7 @@ mod tests { // No force. Install failed. let no_force_result = create_install_shim( &HttpClientProvider::new(None, None), - Flags::default(), + &Flags::default(), InstallFlagsGlobal { module_url: "http://localhost:4545/cat.ts".to_string(), // using a different URL args: vec![], @@ -1246,7 +1247,7 @@ mod tests { // Force. Install success. let force_result = create_install_shim( &HttpClientProvider::new(None, None), - Flags::default(), + &Flags::default(), InstallFlagsGlobal { module_url: "http://localhost:4545/cat.ts".to_string(), // using a different URL args: vec![], @@ -1274,7 +1275,7 @@ mod tests { let result = create_install_shim( &HttpClientProvider::new(None, None), - Flags { + &Flags { config_flag: ConfigFlag::Path(config_file_path.to_string()), ..Flags::default() }, @@ -1307,7 +1308,7 @@ mod tests { create_install_shim( &HttpClientProvider::new(None, None), - Flags::default(), + &Flags::default(), InstallFlagsGlobal { module_url: "http://localhost:4545/echo_server.ts".to_string(), args: vec!["\"".to_string()], @@ -1348,7 +1349,7 @@ mod tests { create_install_shim( &HttpClientProvider::new(None, None), - Flags::default(), + &Flags::default(), InstallFlagsGlobal { module_url: local_module_str.to_string(), args: vec![], @@ -1390,7 +1391,7 @@ mod tests { let result = create_install_shim( &HttpClientProvider::new(None, None), - Flags { + &Flags { import_map_path: Some(import_map_path.to_string()), ..Flags::default() }, @@ -1436,7 +1437,7 @@ mod tests { let result = create_install_shim( &HttpClientProvider::new(None, None), - Flags::default(), + &Flags::default(), InstallFlagsGlobal { module_url: file_module_string.to_string(), args: vec![], |