mirror of
https://github.com/tauri-apps/tauri.git
synced 2026-02-06 14:17:02 +00:00
Co-authored-by: Fabian-Lars <fabianlars@fabianlars.de> Co-authored-by: Lucas Nogueira <lucas@tauri.studio>
41 lines
1.1 KiB
Rust
41 lines
1.1 KiB
Rust
// Copyright 2019-2022 Tauri Programme within The Commons Conservancy
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
#![cfg_attr(
|
|
all(not(debug_assertions), target_os = "windows"),
|
|
windows_subsystem = "windows"
|
|
)]
|
|
|
|
fn main() {
|
|
let mut context = tauri::generate_context!();
|
|
if std::env::var("TARGET").unwrap_or_default() == "nsis" {
|
|
context.config_mut().tauri.updater.windows.installer_args = vec![format!(
|
|
"/D={}",
|
|
std::env::current_exe().unwrap().parent().unwrap().display()
|
|
)];
|
|
}
|
|
tauri::Builder::default()
|
|
.setup(|app| {
|
|
let handle = app.handle();
|
|
tauri::async_runtime::spawn(async move {
|
|
match handle.updater().check().await {
|
|
Ok(update) => {
|
|
if let Err(e) = update.download_and_install().await {
|
|
println!("{e}");
|
|
std::process::exit(1);
|
|
}
|
|
std::process::exit(0);
|
|
}
|
|
Err(e) => {
|
|
println!("{e}");
|
|
std::process::exit(1);
|
|
}
|
|
}
|
|
});
|
|
Ok(())
|
|
})
|
|
.run(context)
|
|
.expect("error while running tauri application");
|
|
}
|