mirror of
https://github.com/github/codeql-action.git
synced 2025-12-18 21:39:15 +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;
|
return output;
|
||||||
}
|
}
|
||||||
function extractFatalErrors(error) {
|
function extractFatalErrors(error) {
|
||||||
const fatalErrors = [];
|
|
||||||
const fatalErrorRegex = /.*fatal error occurred:/gi;
|
const fatalErrorRegex = /.*fatal error occurred:/gi;
|
||||||
|
let fatalErrors = [];
|
||||||
let lastFatalErrorIndex;
|
let lastFatalErrorIndex;
|
||||||
let match;
|
let match;
|
||||||
while ((match = fatalErrorRegex.exec(error)) !== null) {
|
while ((match = fatalErrorRegex.exec(error)) !== null) {
|
||||||
@@ -758,11 +758,21 @@ function extractFatalErrors(error) {
|
|||||||
// No other errors
|
// No other errors
|
||||||
return lastError;
|
return lastError;
|
||||||
}
|
}
|
||||||
const separator = fatalErrors.some((e) => e.includes("\n")) ? "\n" : " ";
|
const isOneLiner = !fatalErrors.some((e) => e.includes("\n"));
|
||||||
return [lastError, "Context:", ...fatalErrors.reverse()].join(separator);
|
if (isOneLiner) {
|
||||||
|
fatalErrors = fatalErrors.map(ensureEndsInPeriod);
|
||||||
|
}
|
||||||
|
return [
|
||||||
|
ensureEndsInPeriod(lastError),
|
||||||
|
"Context:",
|
||||||
|
...fatalErrors.reverse(),
|
||||||
|
].join(isOneLiner ? " " : "\n");
|
||||||
}
|
}
|
||||||
return undefined;
|
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 appropriate, generates a code scanning configuration that is to be used for a scan.
|
||||||
* If the configuration is not to be generated, returns undefined.
|
* If the configuration is not to be generated, returns undefined.
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -1161,8 +1161,8 @@ async function runTool(
|
|||||||
}
|
}
|
||||||
|
|
||||||
function extractFatalErrors(error: string): string | undefined {
|
function extractFatalErrors(error: string): string | undefined {
|
||||||
const fatalErrors: string[] = [];
|
|
||||||
const fatalErrorRegex = /.*fatal error occurred:/gi;
|
const fatalErrorRegex = /.*fatal error occurred:/gi;
|
||||||
|
let fatalErrors: string[] = [];
|
||||||
let lastFatalErrorIndex: number | undefined;
|
let lastFatalErrorIndex: number | undefined;
|
||||||
let match: RegExpMatchArray | null;
|
let match: RegExpMatchArray | null;
|
||||||
while ((match = fatalErrorRegex.exec(error)) !== null) {
|
while ((match = fatalErrorRegex.exec(error)) !== null) {
|
||||||
@@ -1177,12 +1177,23 @@ function extractFatalErrors(error: string): string | undefined {
|
|||||||
// No other errors
|
// No other errors
|
||||||
return lastError;
|
return lastError;
|
||||||
}
|
}
|
||||||
const separator = fatalErrors.some((e) => e.includes("\n")) ? "\n" : " ";
|
const isOneLiner = !fatalErrors.some((e) => e.includes("\n"));
|
||||||
return [lastError, "Context:", ...fatalErrors.reverse()].join(separator);
|
if (isOneLiner) {
|
||||||
|
fatalErrors = fatalErrors.map(ensureEndsInPeriod);
|
||||||
|
}
|
||||||
|
return [
|
||||||
|
ensureEndsInPeriod(lastError),
|
||||||
|
"Context:",
|
||||||
|
...fatalErrors.reverse(),
|
||||||
|
].join(isOneLiner ? " " : "\n");
|
||||||
}
|
}
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function ensureEndsInPeriod(text: string): string {
|
||||||
|
return text[text.length - 1] === "." ? text : `${text}.`;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If appropriate, generates a code scanning configuration that is to be used for a scan.
|
* 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.
|
* If the configuration is not to be generated, returns undefined.
|
||||||
|
|||||||
Reference in New Issue
Block a user