Skip to content

Commit

Permalink
fix(cli/upgrade): nice error when unzip is missing (denoland#12693)
Browse files Browse the repository at this point in the history
Previously just a generic "error: No such file or directory (os error
2)" was printed. Now "`unzip` was not found on your PATH, please install
`unzip`" will be printed.
  • Loading branch information
lucacasonato committed Nov 9, 2021
1 parent f5eb177 commit 22dd1b9
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions cli/tools/upgrade.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

//! This module provides feature to upgrade deno executable

use deno_core::error::{bail, AnyError};
use deno_core::error::bail;
use deno_core::error::AnyError;
use deno_core::futures::StreamExt;
use deno_runtime::deno_fetch::reqwest;
use deno_runtime::deno_fetch::reqwest::Client;
Expand Down Expand Up @@ -262,7 +263,17 @@ pub fn unpack(
Command::new("unzip")
.current_dir(&temp_dir)
.arg(archive_path)
.spawn()?
.spawn()
.map_err(|err| {
if err.kind() == std::io::ErrorKind::NotFound {
std::io::Error::new(
std::io::ErrorKind::NotFound,
"`unzip` was not found on your PATH, please install `unzip`",
)
} else {
err
}
})?
.wait()?
}
ext => panic!("Unsupported archive type: '{}'", ext),
Expand Down

0 comments on commit 22dd1b9

Please sign in to comment.