Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(cli/upgrade): nice error when unzip is missing #12693

Merged
merged 1 commit into from
Nov 9, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fix(cli/upgrade): nice error when unzip is missing
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 8, 2021
commit 00a94d3f5d02c1f39bf6d734cbc18d59e97dc124
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