diff options
author | crowlKats <13135287+crowlKats@users.noreply.github.com> | 2020-07-07 00:21:26 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-06 18:21:26 -0400 |
commit | 2b52e3daf168c6fd0f3d13afcd827cc5b3a284ca (patch) | |
tree | 359409331bd6bdd2ece071769e929d922aa31b2e /cli/upgrade.rs | |
parent | 5c43131be1a36671fd564b82709e11dff66488f3 (diff) |
feat: deno upgrade --output (#6352)
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"); |