bundle standalone node runtime and fix updater prompt race condition

This commit is contained in:
2026-08-22 14:36:16 -07:00
parent c801bb7668
commit af7f236c7e
3 changed files with 60 additions and 18 deletions

View File

@@ -35,8 +35,9 @@ fn clean_path(path: &std::path::Path) -> String {
fn find_node_binary(app: &tauri::App) -> Option<String> {
if let Ok(resource_dir) = app.path().resource_dir() {
let candidates = [
resource_dir.join("node.exe"),
resource_dir.join("bin").join("node.exe"),
resource_dir.join("node.exe"),
resource_dir.join("_up_").join("bin").join("node.exe"),
resource_dir.join("_up_").join("node.exe"),
];
for candidate in candidates {
@@ -46,19 +47,28 @@ fn find_node_binary(app: &tauri::App) -> Option<String> {
}
}
if let Ok(exe_path) = std::env::current_exe() {
if let Some(parent) = exe_path.parent() {
let candidates = [
parent.join("bin").join("node.exe"),
parent.join("node.exe"),
parent.join("resources").join("bin").join("node.exe"),
parent.join("resources").join("node.exe"),
];
for candidate in candidates {
if candidate.exists() {
return Some(clean_path(&candidate));
}
}
}
}
if let Ok(path_var) = std::env::var("PATH") {
for p in std::env::split_paths(&path_var) {
let candidate = p.join("node.exe");
if candidate.exists() {
return Some(clean_path(&candidate));
}
#[cfg(not(windows))]
{
let candidate_unix = p.join("node");
if candidate_unix.exists() {
return Some(clean_path(&candidate_unix));
}
}
}
}
@@ -84,15 +94,6 @@ fn find_node_binary(app: &tauri::App) -> Option<String> {
return Some(clean_path(&candidate));
}
}
if let Ok(app_data) = std::env::var("APPDATA") {
let candidate = std::path::PathBuf::from(app_data)
.join("npm")
.join("node.exe");
if candidate.exists() {
return Some(clean_path(&candidate));
}
}
}
None