diff options
-rw-r--r-- | launcher/src/main.rs | 47 |
1 files changed, 29 insertions, 18 deletions
diff --git a/launcher/src/main.rs b/launcher/src/main.rs index 22617af..73b6862 100644 --- a/launcher/src/main.rs +++ b/launcher/src/main.rs @@ -107,10 +107,16 @@ const BINARY_PATH: &str = "electron"; const BINARY_PATH: &str = "electron.exe"; #[cfg(target_os = "macos")] -const APP_DATA_PATH: &str = "../Resources/app"; +const APP_FOLDER_PATH: &str = "../Resources/app"; #[cfg(any(target_os = "linux", target_os = "windows"))] -const APP_DATA_PATH: &str = "./resources/app"; +const APP_FOLDER_PATH: &str = "./resources/app"; + +#[cfg(target_os = "macos")] +const APP_ASAR_PATH: &str = "../Resources/app.asar"; + +#[cfg(any(target_os = "linux", target_os = "windows"))] +const APP_ASAR_PATH: &str = "./resources/app.asar"; const VERSION: &str = env!("CARGO_PKG_VERSION"); @@ -141,16 +147,25 @@ fn main() { ); let mut found_app = false; - let mut app_path = PathBuf::from(work_dir); - app_path.push(APP_DATA_PATH); + let mut app_is_asar = false; + + let mut app_path_folder = PathBuf::from(work_dir); + app_path_folder.push(APP_FOLDER_PATH); - if app_path.exists() { + let mut app_path_asar = PathBuf::from(work_dir); + app_path_asar.push(APP_ASAR_PATH); + + if app_path_folder.exists() { + found_app = true; + } else if app_path_asar.exists() { found_app = true; + app_is_asar = true; } else { println!( "atomic-launcher: Warning: Could not find Electron-compatible app.\ - Looked in {}. The default atomic-runtime application will be opened instead.", - app_path.to_str().unwrap() + Looked in {} and {}. The default atomic-runtime application will be opened instead.", + app_path_folder.to_str().unwrap(), + app_path_asar.to_str().unwrap() ); } @@ -166,14 +181,6 @@ fn main() { runtime_search_paths_string ); - /*for path in runtime_search_paths { - let path_str = path.to_str().unwrap(); - if path.as_path().exists() && Path::new(&format!("{}/{}", path_str, BINARY_PATH)).exists() { - valid_path = Some(path); - break; - } - }*/ - let runtime_path = runtime_search_paths.into_iter() .filter_map(is_valid_path) .next(); @@ -188,11 +195,15 @@ fn main() { println!("atomic-launcher: Executing: {:?}", cmd); if found_app { - cmd.arg(app_path); + cmd.arg(if app_is_asar { + app_path_asar + } else { + app_path_folder + }) } - if let Ok(mut app) = cmd.spawn() { - process::exit(app.wait().unwrap_or_default().code().unwrap_or(255)); + if let Ok(status) = cmd.status() { + process::exit(status.code().unwrap_or(255)); } else { eprintln!("atomic-launcher: Application failed to start."); process::exit(3); |