From 402ebc9a1f76bffc335565340913302bb39e055d Mon Sep 17 00:00:00 2001 From: Vladislav Mamon Date: Wed, 13 Mar 2024 23:50:15 +0300 Subject: [PATCH] fix(actions/run): clean up error message from script runner (macOS/linux) --- src/actions/actions.rs | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/actions/actions.rs b/src/actions/actions.rs index f96a463..c3e72e6 100644 --- a/src/actions/actions.rs +++ b/src/actions/actions.rs @@ -277,10 +277,25 @@ impl Run { if has_failed { if !err.is_empty() { - eprintln!("{err}"); + // Multiline scripts are run using a temporary shell script, so the errror messages + // sometimes don't look nice, containing the absolute path to that temporary script, e.g.: + // + // /var/folders/81/48f1l9956vjfqzmf9yy24g1c0000gn/T/fsio_1iyUIEI1GJ.sh: line 2: + // + // So here I'm doing dirty string manipulation to clean up the message a bit. + let message = if let Some((_, trailing)) = err.split_once(".sh:") { + trailing.trim().to_string() + } + // TODO: Check error messages on windows (e.g. when trying to run a non-existing command), + // and clean up the message if necessary as well. + else { + err + }; + + eprintln!("{message}"); } - process::exit(1); + process::exit(code); } Ok(println!("{}", output.trim()))