diff options
| author | 魏曹先生 <1992414357@qq.com> | 2026-08-10 18:37:36 +0800 |
|---|---|---|
| committer | 魏曹先生 <1992414357@qq.com> | 2026-08-10 18:37:36 +0800 |
| commit | d652ed8c00bb84503d3f4c75c4a30d6b9827e005 (patch) | |
| tree | 776445d711b1b34435a55b6fc8fb3bfa07087f2b | |
| parent | 8c16b7599563c8bf3ccf555b6e27ddbbc27d8866 (diff) | |
fix(run): emit task failures to stdout on non-TTY
Avoid ProgressBar swallowing error output in CI or piped contexts by
printing directly to stdout when stdout is not a terminal.
| -rw-r--r-- | .run/src/lib.rs | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/.run/src/lib.rs b/.run/src/lib.rs index cff606a..05b8e12 100644 --- a/.run/src/lib.rs +++ b/.run/src/lib.rs @@ -3,6 +3,8 @@ pub mod verify; use colored::Colorize; +use std::io::IsTerminal as _; + #[macro_export] macro_rules! run_cmd { ($fmt:literal, $($arg:tt)*) => { @@ -275,15 +277,30 @@ pub fn run_parallel(phase: &str, tasks: Vec<(String, String, String)>) -> Result if first_exit_code == 0 { first_exit_code = code; } - pb.println(format!( + let msg = format!( "{}: {} failed (exit code {})", "error".bright_red().bold(), labels[i], code, - )); + ); + let mut lines = Vec::new(); if !output.is_empty() { - for line in output.lines() { - pb.println(format!(" {line}")); + lines.extend(output.lines().map(|l| format!(" {l}"))); + } + if std::io::stdout().is_terminal() { + // On a TTY, render errors through the progress bar so they + // appear above it. + pb.println(&msg); + for line in &lines { + pb.println(line); + } + } else { + // On a non-TTY (CI, piped output), `ProgressBar::println` can + // be swallowed, hiding the failure. Emit to plain stdout so the + // failure is always visible. + println!("{msg}"); + for line in &lines { + println!("{line}"); } } } |
