mirror of
https://github.com/denoland/deno.git
synced 2025-03-03 09:31:22 -05:00
fix: don't error on version and help flag (#9064)
This commit is contained in:
parent
6d7da6309e
commit
4361895476
2 changed files with 47 additions and 2 deletions
13
cli/main.rs
13
cli/main.rs
|
@ -1261,8 +1261,17 @@ pub fn main() {
|
|||
std::process::exit(1);
|
||||
}
|
||||
|
||||
let flags =
|
||||
unwrap_or_exit(flags::flags_from_vec(args).map_err(AnyError::from));
|
||||
let flags = match flags::flags_from_vec(args) {
|
||||
Ok(flags) => flags,
|
||||
Err(err @ clap::Error { .. })
|
||||
if err.kind == clap::ErrorKind::HelpDisplayed
|
||||
|| err.kind == clap::ErrorKind::VersionDisplayed =>
|
||||
{
|
||||
err.write_to(&mut std::io::stdout()).unwrap();
|
||||
std::process::exit(0);
|
||||
}
|
||||
Err(err) => unwrap_or_exit(Err(AnyError::from(err))),
|
||||
};
|
||||
if !flags.v8_flags.is_empty() {
|
||||
init_v8_flags(&*flags.v8_flags);
|
||||
}
|
||||
|
|
|
@ -63,6 +63,42 @@ fn std_lint() {
|
|||
assert!(status.success());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn help_flag() {
|
||||
let status = util::deno_cmd()
|
||||
.current_dir(util::root_path())
|
||||
.arg("--help")
|
||||
.spawn()
|
||||
.unwrap()
|
||||
.wait()
|
||||
.unwrap();
|
||||
assert!(status.success());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn version_short_flag() {
|
||||
let status = util::deno_cmd()
|
||||
.current_dir(util::root_path())
|
||||
.arg("-V")
|
||||
.spawn()
|
||||
.unwrap()
|
||||
.wait()
|
||||
.unwrap();
|
||||
assert!(status.success());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn version_long_flag() {
|
||||
let status = util::deno_cmd()
|
||||
.current_dir(util::root_path())
|
||||
.arg("--version")
|
||||
.spawn()
|
||||
.unwrap()
|
||||
.wait()
|
||||
.unwrap();
|
||||
assert!(status.success());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn unit_test_lint() {
|
||||
let status = util::deno_cmd()
|
||||
|
|
Loading…
Add table
Reference in a new issue