Skip to content

Commit a06de37

Browse files
authored
fix(cli): path lookup should not check subfolder before the current one (#3465)
1 parent bf05c3a commit a06de37

File tree

2 files changed

+25
-8
lines changed

2 files changed

+25
-8
lines changed

.changes/fix-cli-lookup.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"cli.rs": patch
3+
"cli.js": patch
4+
---
5+
6+
Check the current folder before checking the directories on the app and tauri dir path lookup function.

tooling/cli/src/helpers/app_paths.rs

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// SPDX-License-Identifier: MIT
44

55
use std::{
6+
cmp::Ordering,
67
env::current_dir,
78
ffi::OsStr,
89
path::{Path, PathBuf},
@@ -25,14 +26,24 @@ fn lookup<F: Fn(&PathBuf) -> bool>(dir: &Path, checker: F) -> Option<PathBuf> {
2526

2627
let mut builder = WalkBuilder::new(dir);
2728
let _ = builder.add_ignore(default_gitignore);
28-
builder.require_git(false).ignore(false).max_depth(Some(
29-
std::env::var("TAURI_PATH_DEPTH")
30-
.map(|d| {
31-
d.parse()
32-
.expect("`TAURI_PATH_DEPTH` environment variable must be a positive integer")
33-
})
34-
.unwrap_or(3),
35-
));
29+
builder
30+
.require_git(false)
31+
.ignore(false)
32+
.max_depth(Some(
33+
std::env::var("TAURI_PATH_DEPTH")
34+
.map(|d| {
35+
d.parse()
36+
.expect("`TAURI_PATH_DEPTH` environment variable must be a positive integer")
37+
})
38+
.unwrap_or(3),
39+
))
40+
.sort_by_file_path(|a, _| {
41+
if a.extension().is_some() {
42+
Ordering::Less
43+
} else {
44+
Ordering::Greater
45+
}
46+
});
3647

3748
for entry in builder.build().flatten() {
3849
let path = dir.join(entry.path());

0 commit comments

Comments
 (0)