From c4abc3ade365a8f81f061130d576d6ea93ae5e56 Mon Sep 17 00:00:00 2001 From: MystiPanda Date: Tue, 16 Jul 2024 18:37:56 +0800 Subject: [PATCH] fix: error command status --- src-tauri/src/core/service.rs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src-tauri/src/core/service.rs b/src-tauri/src/core/service.rs index 54a215ef9..800786d50 100644 --- a/src-tauri/src/core/service.rs +++ b/src-tauri/src/core/service.rs @@ -108,7 +108,7 @@ pub async fn install_service(passwd: String) -> Result<()> { sudo(&passwd, format!("{}", installer_path.to_string_lossy())).output()? } }; - if output.stderr.len() > 0 { + if !output.status.success() { bail!( "failed to install service with error: {}", String::from_utf8_lossy(&output.stderr) @@ -141,8 +141,7 @@ pub async fn install_service(passwd: String) -> Result<()> { ) .output()?; - // MacOS default outout "Password:" in stderr - if output.stderr.len() > 10 { + if !output.status.success() { bail!( "failed to install service with error: {}", String::from_utf8_lossy(&output.stderr) @@ -215,7 +214,8 @@ pub async fn uninstall_service(passwd: String) -> Result<()> { sudo(&passwd, format!("{}", uninstaller_path.to_string_lossy())).output()? } }; - if output.stderr.len() > 0 { + + if !output.status.success() { bail!( "failed to install service with error: {}", String::from_utf8_lossy(&output.stderr) @@ -248,8 +248,7 @@ pub async fn uninstall_service(passwd: String) -> Result<()> { ) .output()?; - // MacOS default outout "Password:" in stderr - if output.stderr.len() > 10 { + if !output.status.success() { bail!( "failed to uninstall service with error: {}", String::from_utf8_lossy(&output.stderr)