Skip to content

Commit d8acbe1

Browse files
authored
fix(cli.rs): app path resolution on projects without git, closes #3409 (#3410)
1 parent d29c5d5 commit d8acbe1

File tree

5 files changed

+31
-4
lines changed

5 files changed

+31
-4
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"cli.rs": patch
3+
"cli.js": patch
4+
---
5+
6+
Fixes Tauri path resolution on projects without Git or a `.gitignore` file.

tooling/cli/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ include = [
1818
"MergeModules/",
1919
"*.json",
2020
"*.rs",
21-
"vswhere.exe"
21+
"vswhere.exe",
22+
"tauri.gitignore"
2223
]
2324

2425
[[bin]]

tooling/cli/schema.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1310,10 +1310,12 @@
13101310
{
13111311
"description": "A variable that is set while calling the command from the webview API.",
13121312
"type": "object",
1313+
"required": [
1314+
"validator"
1315+
],
13131316
"properties": {
13141317
"validator": {
13151318
"description": "[regex] validator to require passed values to conform to an expected input.\n\nThis will require the argument value passed to this variable to match the `validator` regex before it will be executed.\n\n[regex]: https://docs.rs/regex/latest/regex/#syntax",
1316-
"default": "",
13171319
"type": "string"
13181320
}
13191321
},

tooling/cli/src/helpers/app_paths.rs

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,26 @@ use std::{
88
path::{Path, PathBuf},
99
};
1010

11-
use ignore::Walk;
11+
use ignore::WalkBuilder;
1212
use once_cell::sync::Lazy;
1313

14+
const TAURI_GITIGNORE: &[u8] = include_bytes!("../../tauri.gitignore");
15+
1416
fn lookup<F: Fn(&PathBuf) -> bool>(dir: &Path, checker: F) -> Option<PathBuf> {
15-
for entry in Walk::new(dir).flatten() {
17+
let mut default_gitignore = std::env::temp_dir();
18+
default_gitignore.push(".gitignore");
19+
if !default_gitignore.exists() {
20+
if let Ok(mut file) = std::fs::File::create(default_gitignore.clone()) {
21+
use std::io::Write;
22+
let _ = file.write_all(TAURI_GITIGNORE);
23+
}
24+
}
25+
26+
let mut builder = WalkBuilder::new(dir);
27+
let _ = builder.add_ignore(default_gitignore);
28+
builder.require_git(false).ignore(false).max_depth(Some(2));
29+
30+
for entry in builder.build().flatten() {
1631
let path = dir.join(entry.path());
1732
if checker(&path) {
1833
return Some(path);

tooling/cli/tauri.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node_modules/
2+
target/
3+
WixTools

0 commit comments

Comments
 (0)