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

This commit is contained in:
Fabian-Lars
2022-05-26 20:14:43 +02:00
committed by GitHub
parent 569fbd8b40
commit bd8f3e298a
2 changed files with 15 additions and 1 deletions

View File

@@ -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.

View File

@@ -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")