summaryrefslogtreecommitdiff
path: root/cli/tools/upgrade.rs
diff options
context:
space:
mode:
Diffstat (limited to 'cli/tools/upgrade.rs')
-rw-r--r--cli/tools/upgrade.rs12
1 files changed, 7 insertions, 5 deletions
diff --git a/cli/tools/upgrade.rs b/cli/tools/upgrade.rs
index 58c283ecd..ab49c06e9 100644
--- a/cli/tools/upgrade.rs
+++ b/cli/tools/upgrade.rs
@@ -111,7 +111,7 @@ pub async fn upgrade_command(
println!("Deno is upgrading to version {}", &install_version);
let old_exe_path = std::env::current_exe()?;
- let new_exe_path = unpack(archive_data)?;
+ let new_exe_path = unpack(archive_data, "deno")?;
let permissions = fs::metadata(&old_exe_path)?.permissions();
fs::set_permissions(&new_exe_path, permissions)?;
check_exe(&new_exe_path)?;
@@ -176,13 +176,17 @@ async fn download_package(
}
}
-fn unpack(archive_data: Vec<u8>) -> Result<PathBuf, std::io::Error> {
+pub fn unpack(
+ archive_data: Vec<u8>,
+ exe_name: &str,
+) -> Result<PathBuf, std::io::Error> {
// We use into_path so that the tempdir is not automatically deleted. This is
// useful for debugging upgrade, but also so this function can return a path
// to the newly uncompressed file without fear of the tempdir being deleted.
let temp_dir = TempDir::new()?.into_path();
let exe_ext = if cfg!(windows) { "exe" } else { "" };
- let exe_path = temp_dir.join("deno").with_extension(exe_ext);
+ let archive_path = temp_dir.join(exe_name).with_extension(".zip");
+ let exe_path = temp_dir.join(exe_name).with_extension(exe_ext);
assert!(!exe_path.exists());
let archive_ext = Path::new(&*ARCHIVE_NAME)
@@ -191,7 +195,6 @@ fn unpack(archive_data: Vec<u8>) -> Result<PathBuf, std::io::Error> {
.unwrap();
let unpack_status = match archive_ext {
"zip" if cfg!(windows) => {
- let archive_path = temp_dir.join("deno.zip");
fs::write(&archive_path, &archive_data)?;
Command::new("powershell.exe")
.arg("-NoLogo")
@@ -217,7 +220,6 @@ fn unpack(archive_data: Vec<u8>) -> Result<PathBuf, std::io::Error> {
.wait()?
}
"zip" => {
- let archive_path = temp_dir.join("deno.zip");
fs::write(&archive_path, &archive_data)?;
Command::new("unzip")
.current_dir(&temp_dir)