Skip to content

Commit

Permalink
fix(cli): kill beforeDevCommand process if mobile dev command fails (
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasfernog committed Jun 17, 2023
1 parent 655c714 commit 6252380
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 6 deletions.
6 changes: 6 additions & 0 deletions .changes/kill-dev-process-on-err.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"tauri-cli": patch:bug
"@tauri-apps/cli": patch:bug
---

Exit `beforeDevCommand` process if the android or iOS `dev` command fails.
9 changes: 5 additions & 4 deletions tooling/cli/src/dev.rs
Original file line number Diff line number Diff line change
Expand Up @@ -448,10 +448,11 @@ fn check_for_updates() -> Result<()> {
pub fn kill_before_dev_process() {
if let Some(child) = BEFORE_DEV.get() {
let child = child.lock().unwrap();
KILL_BEFORE_DEV_FLAG
.get()
.unwrap()
.store(true, Ordering::Relaxed);
let kill_before_dev_flag = KILL_BEFORE_DEV_FLAG.get().unwrap();
if kill_before_dev_flag.load(Ordering::Relaxed) {
return;
}
kill_before_dev_flag.store(true, Ordering::Relaxed);
#[cfg(windows)]
{
let powershell_path = std::env::var("SYSTEMROOT").map_or_else(
Expand Down
10 changes: 9 additions & 1 deletion tooling/cli/src/mobile/android/dev.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,15 @@ impl From<Options> for DevOptions {
}
}

pub fn command(mut options: Options, noise_level: NoiseLevel) -> Result<()> {
pub fn command(options: Options, noise_level: NoiseLevel) -> Result<()> {
let result = run_command(options, noise_level);
if result.is_err() {
crate::dev::kill_before_dev_process();
}
result
}

fn run_command(mut options: Options, noise_level: NoiseLevel) -> Result<()> {
delete_codegen_vars();

let (merge_config, _merge_config_path) = resolve_merge_config(&options.config)?;
Expand Down
10 changes: 9 additions & 1 deletion tooling/cli/src/mobile/ios/dev.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,15 @@ impl From<Options> for DevOptions {
}
}

pub fn command(mut options: Options, noise_level: NoiseLevel) -> Result<()> {
pub fn command(options: Options, noise_level: NoiseLevel) -> Result<()> {
let result = run_command(options, noise_level);
if result.is_err() {
crate::dev::kill_before_dev_process();
}
result
}

fn run_command(mut options: Options, noise_level: NoiseLevel) -> Result<()> {
if var_os(APPLE_DEVELOPMENT_TEAM_ENV_VAR_NAME).is_none() {
if let Ok(teams) = find_development_teams() {
let index = match teams.len() {
Expand Down

0 comments on commit 6252380

Please sign in to comment.