Skip to content

Commit 0cec873

Browse files
committed
feat: add support for exec()
1 parent ba6e04e commit 0cec873

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/lib.rs

+14
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070
pub use error::*;
7171
use std::{
7272
ffi::OsStr,
73+
os::unix::process::CommandExt,
7374
path::Path,
7475
process::{Command, CommandArgs, CommandEnvs, ExitStatus, Stdio},
7576
};
@@ -168,6 +169,7 @@ impl Cmd {
168169
self.status()?;
169170
Ok(())
170171
}
172+
171173
/// Equivalent to [`std::process::Command::spawn`][],
172174
/// but logged and with the error wrapped.
173175
pub fn spawn(&mut self) -> Result<std::process::Child> {
@@ -213,6 +215,18 @@ impl Cmd {
213215
self.status_inner()
214216
}
215217

218+
/// Equivalent to [`std::process::Command::exec`][]
219+
/// but logged, with the error wrapped
220+
/// Note that, like the original, this will never return on success
221+
pub fn exec(&mut self) -> Result<ExitStatus> {
222+
self.log_command();
223+
let cause = self.inner.exec();
224+
Err(AxoprocessError::Exec {
225+
summary: self.summary.clone(),
226+
cause,
227+
})
228+
}
229+
216230
/// Actual impl of status, split out to support a polyfill
217231
fn status_inner(&mut self) -> Result<ExitStatus> {
218232
self.log_command();

0 commit comments

Comments
 (0)