mirror of
https://github.com/github/codeql-action.git
synced 2025-12-15 03:49:11 +08:00
Improve formatting of fatal errors
This commit is contained in:
16
lib/codeql.js
generated
16
lib/codeql.js
generated
@@ -742,8 +742,8 @@ async function runTool(cmd, args = [], opts = {}) {
|
||||
return output;
|
||||
}
|
||||
function extractFatalErrors(error) {
|
||||
const fatalErrors = [];
|
||||
const fatalErrorRegex = /.*fatal error occurred:/gi;
|
||||
let fatalErrors = [];
|
||||
let lastFatalErrorIndex;
|
||||
let match;
|
||||
while ((match = fatalErrorRegex.exec(error)) !== null) {
|
||||
@@ -758,11 +758,21 @@ function extractFatalErrors(error) {
|
||||
// No other errors
|
||||
return lastError;
|
||||
}
|
||||
const separator = fatalErrors.some((e) => e.includes("\n")) ? "\n" : " ";
|
||||
return [lastError, "Context:", ...fatalErrors.reverse()].join(separator);
|
||||
const isOneLiner = !fatalErrors.some((e) => e.includes("\n"));
|
||||
if (isOneLiner) {
|
||||
fatalErrors = fatalErrors.map(ensureEndsInPeriod);
|
||||
}
|
||||
return [
|
||||
ensureEndsInPeriod(lastError),
|
||||
"Context:",
|
||||
...fatalErrors.reverse(),
|
||||
].join(isOneLiner ? " " : "\n");
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
function ensureEndsInPeriod(text) {
|
||||
return text[text.length - 1] === "." ? text : `${text}.`;
|
||||
}
|
||||
/**
|
||||
* If appropriate, generates a code scanning configuration that is to be used for a scan.
|
||||
* If the configuration is not to be generated, returns undefined.
|
||||
|
||||
Reference in New Issue
Block a user