Skip to content

Commit d62e4f4

Browse files
author
Andrew
committed
clippy 2
1 parent 80e7cbf commit d62e4f4

File tree

1 file changed

+17
-16
lines changed

1 file changed

+17
-16
lines changed

dsc_lib/src/dscresources/command_resource.rs

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -628,25 +628,22 @@ async fn run_process_async(executable: &str, args: Option<Vec<String>>, input: O
628628
let stdout_result = stdout_task.await.unwrap();
629629
let stderr_result = stderr_task.await.unwrap();
630630

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()));
640638
}
641-
return Err(DscError::Command(executable.to_string(), code, stderr_result));
642639
}
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));
649641
}
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()))
650647
}
651648
}
652649
/// 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
661658
/// # Errors
662659
///
663660
/// 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+
///
664665
#[allow(clippy::implicit_hasher)]
665666
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> {
666667
debug!("Invoking command '{}' with args {:?}", executable, args);

0 commit comments

Comments
 (0)