match -> if let

This commit is contained in:
SkyfallWasTaken 2024-07-15 21:09:49 +01:00
parent f742244f95
commit 396b6d7124

View file

@ -11,15 +11,13 @@ pub async fn run(script_name: Option<String>) -> Result<()> {
let Some(scripts) = package_json.scripts else {
return Err(eyre!("no `scripts` provided in package.json"));
};
match script_name {
Some(script_name) => {
if let Some(script_name) = script_name {
match scripts.get(&script_name) {
Some(script) => {
println!("{} {}", "$".purple().dimmed(), script.bold().dimmed());
let status =
run_script(DEFAULT_SHELL, DEFAULT_SHELL_EXEC_ARG, script, root_path)
.await?;
run_script(DEFAULT_SHELL, DEFAULT_SHELL_EXEC_ARG, script, root_path).await?;
if cfg!(unix) {
use std::os::unix::process::ExitStatusExt;
@ -38,14 +36,12 @@ pub async fn run(script_name: Option<String>) -> Result<()> {
}
_ => return Err(eyre!(format!("script `{script_name}` not found"))),
}
}
_ => {
} else {
println!("{}", "Available scripts:".bold().underline());
for (key, val) in &scripts {
println!("{} - {}", key.bold(), val.dimmed());
}
}
}
Ok(())
}