From 2e53cdcad7e92810e62a1c523b6683171a5f4b14 Mon Sep 17 00:00:00 2001 From: Filip Tibell Date: Mon, 25 Sep 2023 12:41:56 -0500 Subject: [PATCH] Fix list subcommand not listing global dir without a local dir --- CHANGELOG.md | 1 + src/cli/mod.rs | 23 +++++++++-------------- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 934cc67..25234ed 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -61,6 +61,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed +- Fixed list subcommand not listing global scripts without a local `.lune` / `lune` directory present - Fixed `net.serve` stopping when the returned `ServeHandle` is garbage collected - Fixed missing trailing newline when using the `warn` global - Fixed constructor for `CFrame` in the `roblox` built-in library not parsing the 12-arg overload correctly. ([#102]) diff --git a/src/cli/mod.rs b/src/cli/mod.rs index ccc11ae..9a80c9d 100644 --- a/src/cli/mod.rs +++ b/src/cli/mod.rs @@ -83,20 +83,15 @@ impl Cli { // List files in `lune` and `.lune` directories, if wanted // This will also exit early and not run anything else if self.list { - let sorted_relative = match find_lune_scripts(false).await { - Ok(scripts) => sort_lune_scripts(scripts), - Err(e) => { - eprintln!("{e}"); - return Ok(ExitCode::FAILURE); - } - }; - let sorted_home_dir = match find_lune_scripts(true).await { - Ok(scripts) => sort_lune_scripts(scripts), - Err(e) => { - eprintln!("{e}"); - return Ok(ExitCode::FAILURE); - } - }; + let sorted_relative = find_lune_scripts(false).await.map(sort_lune_scripts); + let sorted_home_dir = find_lune_scripts(true).await.map(sort_lune_scripts); + if sorted_relative.is_err() && sorted_home_dir.is_err() { + eprintln!("{}", sorted_relative.unwrap_err()); + return Ok(ExitCode::FAILURE); + } + + let sorted_relative = sorted_relative.unwrap_or(Vec::new()); + let sorted_home_dir = sorted_home_dir.unwrap_or(Vec::new()); let mut buffer = String::new(); if !sorted_relative.is_empty() {