Skip to content

Commit

Permalink
CommandList: add a method to run all the commands in foreground (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
cecton authored Feb 6, 2024
1 parent 3e3e4ba commit aa5ee44
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
//! ## A basic implementation
//!
//! ```rust,no_run
//! use std::process::Command;
//! use std::process::{Command, ExitStatus};
//! use xtask_watch::{
//! anyhow::Result,
//! clap,
Expand Down Expand Up @@ -559,6 +559,18 @@ impl CommandList {
}
}
}

/// Run all the commands sequentially using [`std::process::Command::status`] and stop at the
/// first failure.
pub fn status(&mut self) -> io::Result<ExitStatus> {
for process in self.commands.lock().expect("not poisoned").iter_mut() {
let exit_status = process.status()?;
if !exit_status.success() {
return Ok(exit_status);
}
}
Ok(Default::default())
}
}

#[cfg(test)]
Expand Down

0 comments on commit aa5ee44

Please sign in to comment.