Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
May 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changes/cli-fix-gitignored-conf-lookup.md
Original file line number Diff line number Diff line change
@@ -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.
10 changes: 9 additions & 1 deletion tooling/cli/src/helpers/app_paths.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down