Like [`Task::run`], but return stdout.
(self)
| 163 | |
| 164 | /// Like [`Task::run`], but return stdout. |
| 165 | pub(crate) fn read(self) -> Result<String> { |
| 166 | self.pre_run_output(); |
| 167 | let description = self.description; |
| 168 | let mut cmd = self.cmd; |
| 169 | tracing::debug!("exec: {cmd:?}"); |
| 170 | cmd.stdout(Stdio::piped()); |
| 171 | let child = cmd |
| 172 | .spawn() |
| 173 | .with_context(|| format!("Spawning {description} failed"))?; |
| 174 | let o = child |
| 175 | .wait_with_output() |
| 176 | .with_context(|| format!("Executing {description} failed"))?; |
| 177 | let st = o.status; |
| 178 | if !st.success() { |
| 179 | anyhow::bail!("Task {description} failed: {st:?}"); |
| 180 | } |
| 181 | Ok(String::from_utf8(o.stdout)?) |
| 182 | } |
| 183 | |
| 184 | pub(crate) fn new_and_run<'a>( |
| 185 | description: impl AsRef<str>, |