Truncate autobuild errors to 10 lines

This commit is contained in:
Henry Mercer
2024-03-15 11:24:50 +00:00
parent 88a0b7abb3
commit 3edd1bf725
6 changed files with 61 additions and 8 deletions

9
lib/cli-errors.js generated
View File

@@ -103,8 +103,13 @@ function extractFatalErrors(error) {
}
function extractAutobuildErrors(error) {
const pattern = /.*\[autobuild\] \[ERROR\] (.*)/gi;
return ([...error.matchAll(pattern)].map((match) => match[1]).join("\n") ||
undefined);
let errorLines = [...error.matchAll(pattern)].map((match) => match[1]);
// Truncate if there are more than 10 matching lines.
if (errorLines.length > 10) {
errorLines = errorLines.slice(0, 10);
errorLines.push("(truncated)");
}
return errorLines.join("\n") || undefined;
}
function ensureEndsInPeriod(text) {
return text[text.length - 1] === "." ? text : `${text}.`;