소스 검색

fix(cli): path lookup should not check subfolder before the current one (#3465)

Lucas Fernandes Nogueira 3 년 전
부모
커밋
a06de37601
2개의 변경된 파일25개의 추가작업 그리고 8개의 파일을 삭제
  1. 6 0
      .changes/fix-cli-lookup.md
  2. 19 8
      tooling/cli/src/helpers/app_paths.rs

+ 6 - 0
.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.

+ 19 - 8
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<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());