@@ -628,25 +628,22 @@ async fn run_process_async(executable: &str, args: Option<Vec<String>>, input: O
628
628
let stdout_result = stdout_task. await . unwrap ( ) ;
629
629
let stderr_result = stderr_task. await . unwrap ( ) ;
630
630
631
- match exit_code {
632
- Some ( code) => {
633
- debug ! ( "Process '{executable}' id {child_id} exited with code {code}" ) ;
634
-
635
- if code != 0 {
636
- if let Some ( exit_codes) = exit_codes {
637
- if let Some ( error_message) = exit_codes. get ( & code) {
638
- return Err ( DscError :: CommandExitFromManifest ( executable. to_string ( ) , code, error_message. to_string ( ) ) ) ;
639
- }
631
+ if let Some ( code) = exit_code {
632
+ debug ! ( "Process '{executable}' id {child_id} exited with code {code}" ) ;
633
+
634
+ if code != 0 {
635
+ if let Some ( exit_codes) = exit_codes {
636
+ if let Some ( error_message) = exit_codes. get ( & code) {
637
+ return Err ( DscError :: CommandExitFromManifest ( executable. to_string ( ) , code, error_message. to_string ( ) ) ) ;
640
638
}
641
- return Err ( DscError :: Command ( executable. to_string ( ) , code, stderr_result) ) ;
642
639
}
643
-
644
- Ok ( ( code, stdout_result, stderr_result) )
645
- } ,
646
- None => {
647
- debug ! ( "Process '{executable}' id {child_id} terminated by signal" ) ;
648
- Err ( DscError :: CommandOperation ( "Process terminated by signal" . to_string ( ) , executable. to_string ( ) ) )
640
+ return Err ( DscError :: Command ( executable. to_string ( ) , code, stderr_result) ) ;
649
641
}
642
+
643
+ Ok ( ( code, stdout_result, stderr_result) )
644
+ } else {
645
+ debug ! ( "Process '{executable}' id {child_id} terminated by signal" ) ;
646
+ Err ( DscError :: CommandOperation ( "Process terminated by signal" . to_string ( ) , executable. to_string ( ) ) )
650
647
}
651
648
}
652
649
/// Invoke a command and return the exit code, stdout, and stderr.
@@ -661,6 +658,10 @@ async fn run_process_async(executable: &str, args: Option<Vec<String>>, input: O
661
658
/// # Errors
662
659
///
663
660
/// Error is returned if the command fails to execute or stdin/stdout/stderr cannot be opened.
661
+ /// # Panics
662
+ ///
663
+ /// Will panic if tokio runtime can't be created.
664
+ ///
664
665
#[ allow( clippy:: implicit_hasher) ]
665
666
pub fn invoke_command ( executable : & str , args : Option < Vec < String > > , input : Option < & str > , cwd : Option < & str > , env : Option < HashMap < String , String > > , exit_codes : & Option < HashMap < i32 , String > > ) -> Result < ( i32 , String , String ) , DscError > {
666
667
debug ! ( "Invoking command '{}' with args {:?}" , executable, args) ;
0 commit comments