diff options
author | Luca Casonato <hello@lcas.dev> | 2021-11-09 11:06:45 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-09 11:06:45 +0100 |
commit | 22dd1b90c4eb5671decd458cc70935898f9ccf0d (patch) | |
tree | 4a83bdfbdb0e616e53342d77be4eb12c37a811c8 | |
parent | f5eb177f50a0bf37bc6bd9d87b447c73a53b6ea5 (diff) |
fix(cli/upgrade): nice error when unzip is missing (#12693)
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.
-rw-r--r-- | cli/tools/upgrade.rs | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/cli/tools/upgrade.rs b/cli/tools/upgrade.rs index 752929b94..6de8ba932 100644 --- a/cli/tools/upgrade.rs +++ b/cli/tools/upgrade.rs @@ -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; @@ -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), |