mirror of
https://github.com/tauri-apps/tauri.git
synced 2026-01-31 00:35:19 +01:00
fix(cli): Re-add TriggeredKill in dev watcher logic (#12178)
This commit is contained in:
6
.changes/cli-watcher-exit-on-change.md
Normal file
6
.changes/cli-watcher-exit-on-change.md
Normal file
@@ -0,0 +1,6 @@
|
||||
---
|
||||
'tauri-cli': 'patch:bug'
|
||||
'@tauri-apps/cli': 'patch:bug'
|
||||
---
|
||||
|
||||
Fixed an issue that caused the `tauri dev` file watcher to exit after detecting file changes.
|
||||
@@ -339,7 +339,10 @@ pub fn setup(interface: &AppInterface, options: &mut Options, config: ConfigHand
|
||||
}
|
||||
|
||||
pub fn on_app_exit(code: Option<i32>, reason: ExitReason, exit_on_panic: bool, no_watch: bool) {
|
||||
if no_watch || exit_on_panic || matches!(reason, ExitReason::NormalExit) {
|
||||
if no_watch
|
||||
|| (!matches!(reason, ExitReason::TriggeredKill)
|
||||
&& (exit_on_panic || matches!(reason, ExitReason::NormalExit)))
|
||||
{
|
||||
kill_before_dev_process();
|
||||
exit(code.unwrap_or(0));
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ pub trait AppSettings {
|
||||
#[derive(Debug)]
|
||||
pub enum ExitReason {
|
||||
/// Killed manually.
|
||||
// TriggeredKill,
|
||||
TriggeredKill,
|
||||
/// App compilation failed.
|
||||
CompilationFailed,
|
||||
/// Regular exit.
|
||||
|
||||
@@ -553,7 +553,6 @@ impl Rust {
|
||||
loop {
|
||||
if let Ok(events) = rx.recv() {
|
||||
for event in events {
|
||||
#[cfg(target_os = "linux")]
|
||||
if event.kind.is_access() {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -78,6 +78,9 @@ pub fn run_dev<F: Fn(Option<i32>, ExitReason) + Send + Sync + 'static>(
|
||||
dev_cmd.arg("--");
|
||||
dev_cmd.args(run_args);
|
||||
|
||||
let manually_killed_app = Arc::new(AtomicBool::default());
|
||||
let manually_killed_app_ = manually_killed_app.clone();
|
||||
|
||||
let dev_child = match SharedChild::spawn(&mut dev_cmd) {
|
||||
Ok(c) => Ok(c),
|
||||
Err(e) if e.kind() == ErrorKind::NotFound => Err(anyhow::anyhow!(
|
||||
@@ -128,6 +131,8 @@ pub fn run_dev<F: Fn(Option<i32>, ExitReason) + Send + Sync + 'static>(
|
||||
status.code(),
|
||||
if status.code() == Some(101) && is_cargo_compile_error {
|
||||
ExitReason::CompilationFailed
|
||||
} else if manually_killed_app_.load(Ordering::Relaxed) {
|
||||
ExitReason::TriggeredKill
|
||||
} else {
|
||||
ExitReason::NormalExit
|
||||
},
|
||||
@@ -135,9 +140,6 @@ pub fn run_dev<F: Fn(Option<i32>, ExitReason) + Send + Sync + 'static>(
|
||||
}
|
||||
});
|
||||
|
||||
// TODO: remove this and DevChild (requires refactor for code shared between mobile and desktop)
|
||||
let manually_killed_app = Arc::new(AtomicBool::default());
|
||||
|
||||
Ok(DevChild {
|
||||
manually_killed_app,
|
||||
dev_child,
|
||||
|
||||
Reference in New Issue
Block a user