mirror of
https://github.com/tauri-apps/tauri.git
synced 2024-12-25 03:33:36 +03:00
This commit is contained in:
parent
d29c5d551f
commit
d8acbe1149
6
.changes/fix-path-resolution-node_modules.md
Normal file
6
.changes/fix-path-resolution-node_modules.md
Normal file
@ -0,0 +1,6 @@
|
||||
---
|
||||
"cli.rs": patch
|
||||
"cli.js": patch
|
||||
---
|
||||
|
||||
Fixes Tauri path resolution on projects without Git or a `.gitignore` file.
|
@ -18,7 +18,8 @@ include = [
|
||||
"MergeModules/",
|
||||
"*.json",
|
||||
"*.rs",
|
||||
"vswhere.exe"
|
||||
"vswhere.exe",
|
||||
"tauri.gitignore"
|
||||
]
|
||||
|
||||
[[bin]]
|
||||
|
@ -1310,10 +1310,12 @@
|
||||
{
|
||||
"description": "A variable that is set while calling the command from the webview API.",
|
||||
"type": "object",
|
||||
"required": [
|
||||
"validator"
|
||||
],
|
||||
"properties": {
|
||||
"validator": {
|
||||
"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",
|
||||
"default": "",
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
|
@ -8,11 +8,26 @@ use std::{
|
||||
path::{Path, PathBuf},
|
||||
};
|
||||
|
||||
use ignore::Walk;
|
||||
use ignore::WalkBuilder;
|
||||
use once_cell::sync::Lazy;
|
||||
|
||||
const TAURI_GITIGNORE: &[u8] = include_bytes!("../../tauri.gitignore");
|
||||
|
||||
fn lookup<F: Fn(&PathBuf) -> bool>(dir: &Path, checker: F) -> Option<PathBuf> {
|
||||
for entry in Walk::new(dir).flatten() {
|
||||
let mut default_gitignore = std::env::temp_dir();
|
||||
default_gitignore.push(".gitignore");
|
||||
if !default_gitignore.exists() {
|
||||
if let Ok(mut file) = std::fs::File::create(default_gitignore.clone()) {
|
||||
use std::io::Write;
|
||||
let _ = file.write_all(TAURI_GITIGNORE);
|
||||
}
|
||||
}
|
||||
|
||||
let mut builder = WalkBuilder::new(dir);
|
||||
let _ = builder.add_ignore(default_gitignore);
|
||||
builder.require_git(false).ignore(false).max_depth(Some(2));
|
||||
|
||||
for entry in builder.build().flatten() {
|
||||
let path = dir.join(entry.path());
|
||||
if checker(&path) {
|
||||
return Some(path);
|
||||
|
3
tooling/cli/tauri.gitignore
Normal file
3
tooling/cli/tauri.gitignore
Normal file
@ -0,0 +1,3 @@
|
||||
node_modules/
|
||||
target/
|
||||
WixTools
|
Loading…
Reference in New Issue
Block a user