Skip to content

Commit

Permalink
fix(bossy): regression on checking status code (#102)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasfernog authored Feb 19, 2023
1 parent 6004ce2 commit 15b9420
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
5 changes: 5 additions & 0 deletions .changes/command-run-handle-error.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"tauri-mobile": patch
---

Fixes regression when running commands and checking status code.
24 changes: 11 additions & 13 deletions src/bossy/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -351,26 +351,24 @@ impl Command {
log::trace!("running command {:?} and waiting for exit", self.display);
self.set_stdout(os_pipe::dup_stdout().unwrap());
self.set_stderr(os_pipe::dup_stderr().unwrap());
self.inner.status().map_err(|e| Error {
command: self.display.clone(),
cause: Cause::SpawnFailed(e),
})
self.inner
.status()
.map_err(|e| Error {
command: self.display.clone(),
cause: Cause::SpawnFailed(e),
})
.and_then(|status| Error::from_status_result(self.display.clone(), Ok(status)))
}

/// Run the command and block until its output is collected. This will
/// automatically set stdout and stderr to use [`Stdio::piped`], so if you
/// don't want that to happen, then you're screwed.
pub fn run_and_wait_for_output(&mut self) -> Result<Output> {
log::trace!("running command {:?} and waiting for output", self.display);
self.set_stdout_piped()
.set_stderr_piped()
.inner
.output()
.map(|o| Output::new(self.display.clone(), o))
.map_err(|e| Error {
command: self.display.clone(),
cause: Cause::SpawnFailed(e),
})
Error::from_output_result(
self.display.clone(),
self.set_stdout_piped().set_stderr_piped().inner.output(),
)
}

pub fn run_and_wait_for_str<T>(&mut self, f: impl FnOnce(&str) -> T) -> Result<T> {
Expand Down

0 comments on commit 15b9420

Please sign in to comment.