mirror of
https://gitlab.com/vyla-entertainment/home.git
synced 2026-11-09 19:57:20 -05:00
add macOS Node runtime and appdata support
This commit is contained in:
13
main.js
13
main.js
@@ -6,10 +6,19 @@ const ServiceManager = require('./service-manager');
|
||||
const Patcher = require('./patcher');
|
||||
const UpdateClient = require('./update-client');
|
||||
|
||||
const defaultAppData = path.join(os.homedir(), 'AppData', 'Roaming', 'vyla-home', 'vyla-home-files');
|
||||
function getDefaultAppData() {
|
||||
if (process.platform === 'darwin') {
|
||||
return path.join(os.homedir(), 'Library', 'Application Support', 'vyla-home', 'vyla-home-files');
|
||||
}
|
||||
if (process.platform === 'linux') {
|
||||
return path.join(os.homedir(), '.local', 'share', 'vyla-home', 'vyla-home-files');
|
||||
}
|
||||
return path.join(os.homedir(), 'AppData', 'Roaming', 'vyla-home', 'vyla-home-files');
|
||||
}
|
||||
|
||||
const APPDATA_DIR = (process.env.APPDATA_PATH && !process.env.APPDATA_PATH.includes('com.vyla.home'))
|
||||
? process.env.APPDATA_PATH
|
||||
: defaultAppData;
|
||||
: getDefaultAppData();
|
||||
|
||||
const LOGS_DIR = path.join(APPDATA_DIR, 'logs');
|
||||
try { fs.mkdirSync(LOGS_DIR, { recursive: true }); } catch (e) { }
|
||||
|
||||
@@ -60,9 +60,13 @@ fn find_node_binary(app: &tauri::App) -> Option<String> {
|
||||
if let Ok(resource_dir) = app.path().resource_dir() {
|
||||
let candidates = [
|
||||
resource_dir.join("bin").join("node.exe"),
|
||||
resource_dir.join("bin").join("node"),
|
||||
resource_dir.join("node.exe"),
|
||||
resource_dir.join("node"),
|
||||
resource_dir.join("_up_").join("bin").join("node.exe"),
|
||||
resource_dir.join("_up_").join("bin").join("node"),
|
||||
resource_dir.join("_up_").join("node.exe"),
|
||||
resource_dir.join("_up_").join("node"),
|
||||
];
|
||||
for candidate in candidates {
|
||||
if candidate.exists() {
|
||||
@@ -75,9 +79,13 @@ fn find_node_binary(app: &tauri::App) -> Option<String> {
|
||||
if let Some(parent) = exe_path.parent() {
|
||||
let candidates = [
|
||||
parent.join("bin").join("node.exe"),
|
||||
parent.join("bin").join("node"),
|
||||
parent.join("node.exe"),
|
||||
parent.join("node"),
|
||||
parent.join("resources").join("bin").join("node.exe"),
|
||||
parent.join("resources").join("bin").join("node"),
|
||||
parent.join("resources").join("node.exe"),
|
||||
parent.join("resources").join("node"),
|
||||
];
|
||||
for candidate in candidates {
|
||||
if candidate.exists() {
|
||||
@@ -89,9 +97,13 @@ fn find_node_binary(app: &tauri::App) -> Option<String> {
|
||||
|
||||
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));
|
||||
let node_exe = p.join("node.exe");
|
||||
if node_exe.exists() {
|
||||
return Some(clean_path(&node_exe));
|
||||
}
|
||||
let node = p.join("node");
|
||||
if node.exists() {
|
||||
return Some(clean_path(&node));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -120,6 +132,22 @@ fn find_node_binary(app: &tauri::App) -> Option<String> {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(windows))]
|
||||
{
|
||||
let default_paths = [
|
||||
"/usr/local/bin/node",
|
||||
"/usr/bin/node",
|
||||
"/opt/homebrew/bin/node",
|
||||
"/opt/local/bin/node",
|
||||
];
|
||||
for path in default_paths {
|
||||
let candidate = std::path::Path::new(path);
|
||||
if candidate.exists() {
|
||||
return Some(clean_path(candidate));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
None
|
||||
}
|
||||
|
||||
@@ -622,10 +650,12 @@ fn main() {
|
||||
}
|
||||
};
|
||||
|
||||
let vyla_files_str = clean_path(&vyla_files);
|
||||
|
||||
let mut cmd = Command::new(&node_bin);
|
||||
cmd.arg(&main_js)
|
||||
.current_dir(&root_dir)
|
||||
.env("APPDATA_PATH", &app_data_str)
|
||||
.env("APPDATA_PATH", &vyla_files_str)
|
||||
.env("NODE_EXE", &node_bin)
|
||||
.stdin(Stdio::piped())
|
||||
.stdout(Stdio::piped())
|
||||
|
||||
Reference in New Issue
Block a user