Skip to content

Commit

Permalink
fix(cli): path lookup should not check subfolder before the current o…
Browse files Browse the repository at this point in the history
…ne (#3465)
  • Loading branch information
lucasfernog committed Feb 15, 2022
1 parent bf05c3a commit a06de37
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 8 deletions.
6 changes: 6 additions & 0 deletions .changes/fix-cli-lookup.md
Original file line number Diff line number Diff line change
@@ -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.
27 changes: 19 additions & 8 deletions tooling/cli/src/helpers/app_paths.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// SPDX-License-Identifier: MIT

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

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());
Expand Down

0 comments on commit a06de37

Please sign in to comment.