From a06de3760184caa71acfe7a2fe2189a033b565f5 Mon Sep 17 00:00:00 2001 From: Lucas Fernandes Nogueira Date: Tue, 15 Feb 2022 11:40:21 -0300 Subject: [PATCH] fix(cli): path lookup should not check subfolder before the current one (#3465) --- .changes/fix-cli-lookup.md | 6 ++++++ tooling/cli/src/helpers/app_paths.rs | 27 +++++++++++++++++++-------- 2 files changed, 25 insertions(+), 8 deletions(-) create mode 100644 .changes/fix-cli-lookup.md diff --git a/.changes/fix-cli-lookup.md b/.changes/fix-cli-lookup.md new file mode 100644 index 000000000..6ed43e850 --- /dev/null +++ b/.changes/fix-cli-lookup.md @@ -0,0 +1,6 @@ +--- +"cli.rs": patch +"cli.js": patch +--- + +Check the current folder before checking the directories on the app and tauri dir path lookup function. diff --git a/tooling/cli/src/helpers/app_paths.rs b/tooling/cli/src/helpers/app_paths.rs index a89eafdf7..6ee7b78a4 100644 --- a/tooling/cli/src/helpers/app_paths.rs +++ b/tooling/cli/src/helpers/app_paths.rs @@ -3,6 +3,7 @@ // SPDX-License-Identifier: MIT use std::{ + cmp::Ordering, env::current_dir, ffi::OsStr, path::{Path, PathBuf}, @@ -25,14 +26,24 @@ fn lookup bool>(dir: &Path, checker: F) -> Option { let mut builder = WalkBuilder::new(dir); let _ = builder.add_ignore(default_gitignore); - builder.require_git(false).ignore(false).max_depth(Some( - std::env::var("TAURI_PATH_DEPTH") - .map(|d| { - d.parse() - .expect("`TAURI_PATH_DEPTH` environment variable must be a positive integer") - }) - .unwrap_or(3), - )); + builder + .require_git(false) + .ignore(false) + .max_depth(Some( + std::env::var("TAURI_PATH_DEPTH") + .map(|d| { + d.parse() + .expect("`TAURI_PATH_DEPTH` environment variable must be a positive integer") + }) + .unwrap_or(3), + )) + .sort_by_file_path(|a, _| { + if a.extension().is_some() { + Ordering::Less + } else { + Ordering::Greater + } + }); for entry in builder.build().flatten() { let path = dir.join(entry.path());