瀏覽代碼

fix(cli): manual config lookup to handle gitignored folders, fixes #3527 (#4224)

Fabian-Lars 3 年之前
父節點
當前提交
bd8f3e298a
共有 2 個文件被更改,包括 15 次插入1 次删除
  1. 6 0
      .changes/cli-fix-gitignored-conf-lookup.md
  2. 9 1
      tooling/cli/src/helpers/app_paths.rs

+ 6 - 0
.changes/cli-fix-gitignored-conf-lookup.md

@@ -0,0 +1,6 @@
+---
+"cli.rs": patch
+"cli.js": patch
+---
+
+Check if `$CWD/src-tauri/tauri.conf.json` exists before walking through the file tree to find the tauri dir in case the whole project is gitignored.

+ 9 - 1
tooling/cli/src/helpers/app_paths.rs

@@ -56,7 +56,15 @@ fn lookup<F: Fn(&PathBuf, FileType) -> bool>(dir: &Path, checker: F) -> Option<P
 }
 
 fn get_tauri_dir() -> PathBuf {
-  lookup(&current_dir().expect("failed to read cwd"), |path, file_type| if file_type.is_dir() {
+  let cwd = current_dir().expect("failed to read cwd");
+
+  if cwd.join("src-tauri/tauri.conf.json").exists()
+    || cwd.join("src-tauri/tauri.conf.json5").exists()
+  {
+    return cwd.join("src-tauri/");
+  }
+
+  lookup(&cwd, |path, file_type| if file_type.is_dir() {
     path.join("tauri.conf.json").exists() || path.join("tauri.conf.json5").exists()
   } else if let Some(file_name) = path.file_name() {
     file_name == OsStr::new("tauri.conf.json") || file_name == OsStr::new("tauri.conf.json5")