diff options
Diffstat (limited to 'cli/upgrade.rs')
-rw-r--r-- | cli/upgrade.rs | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/cli/upgrade.rs b/cli/upgrade.rs index 9f3e0459d..244bf6c8a 100644 --- a/cli/upgrade.rs +++ b/cli/upgrade.rs @@ -56,6 +56,7 @@ pub async fn upgrade_command( dry_run: bool, force: bool, version: Option<String>, + output: Option<PathBuf>, ca_file: Option<String>, ) -> Result<(), ErrBox> { let mut client_builder = Client::builder().redirect(Policy::none()); @@ -76,7 +77,7 @@ pub async fn upgrade_command( Ok(ver) => { if !force && current_version == ver { println!("Version {} is already installed", &ver); - std::process::exit(1) + return Ok(()); } else { ver } @@ -94,7 +95,7 @@ pub async fn upgrade_command( "Local deno version {} is the most recent release", &crate::version::DENO ); - std::process::exit(1) + return Ok(()); } else { latest_version } @@ -114,7 +115,13 @@ pub async fn upgrade_command( check_exe(&new_exe_path, &install_version)?; if !dry_run { - replace_exe(&new_exe_path, &old_exe_path)?; + match output { + Some(path) => { + fs::rename(&new_exe_path, &path) + .or_else(|_| fs::copy(&new_exe_path, &path).map(|_| ()))?; + } + None => replace_exe(&new_exe_path, &old_exe_path)?, + } } println!("Upgrade done successfully"); |