fix: panic when piping "deno help" or "deno --version" (#22917)

Fixes #22863

---------

Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
This commit is contained in:
muddlebee 2024-07-10 04:27:00 +05:30 committed by GitHub
parent fb6348500f
commit 9776a13e33
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 21 additions and 1 deletions

View file

@ -347,7 +347,8 @@ fn resolve_flags_and_init(
if err.kind() == clap::error::ErrorKind::DisplayHelp
|| err.kind() == clap::error::ErrorKind::DisplayVersion =>
{
err.print().unwrap();
// Ignore results to avoid BrokenPipe errors.
let _ = err.print();
std::process::exit(0);
}
Err(err) => exit_for_error(AnyError::from(err)),

View file

@ -0,0 +1,9 @@
{
"steps": [{
"args": "task help",
"output": "help.out"
}, {
"args": "task version",
"output": "version.out"
}]
}

View file

@ -0,0 +1,6 @@
{
"tasks": {
"help": "deno help | echo",
"version": "deno --version | echo"
}
}

View file

@ -0,0 +1,2 @@
Task help deno help | echo

View file

@ -0,0 +1,2 @@
Task version deno --version | echo