fix(cli): kill beforeDevCommand process if mobile dev command fails (#7241)

This commit is contained in:
Lucas Fernandes Nogueira 2023-06-17 10:10:01 -07:00 committed by GitHub
parent 655c714e41
commit 6252380f44
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 29 additions and 6 deletions

View File

@ -0,0 +1,6 @@
---
"tauri-cli": patch:bug
"@tauri-apps/cli": patch:bug
---
Exit `beforeDevCommand` process if the android or iOS `dev` command fails.

View File

@ -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(

View File

@ -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)?;

View File

@ -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() {