Merge pull request #2196 from zed-industries/open_urls

Fix open URLs, restarts, and make bundling easier to use
This commit is contained in:
Mikayla Maki 2023-02-21 15:36:50 -08:00 committed by GitHub
commit 14488619a3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 80 additions and 41 deletions

View file

@ -829,17 +829,24 @@ impl platform::Platform for MacPlatform {
fn restart(&self) {
#[cfg(debug_assertions)]
let path = std::env::current_exe();
let path = std::env::current_exe().unwrap();
#[cfg(not(debug_assertions))]
let path = self.app_path().or_else(|_| std::env::current_exe());
let path = self
.app_path()
.unwrap_or_else(|_| std::env::current_exe().unwrap());
let command = path.and_then(|path| Command::new("/usr/bin/open").arg(path).spawn());
let script = r#"lsof -p "$0" +r 1 &>/dev/null && open "$1""#;
match command {
Err(err) => log::error!("Unable to restart application {}", err),
Ok(_child) => self.quit(),
}
Command::new("/bin/bash")
.arg("-c")
.arg(script)
.arg(std::process::id().to_string())
.arg(path)
.spawn()
.ok();
self.quit();
}
}