mirror of
https://github.com/github/codeql-action.git
synced 2026-10-21 02:01:27 +00:00
Refactor writeTemporaryDiagnosticFile out of add[NoLanguage]Diagnostic
This commit is contained in:
17
lib/entry-points.js
generated
17
lib/entry-points.js
generated
@@ -173005,9 +173005,7 @@ function addDiagnostic(config, language, diagnostic, logger2 = getActionsLogger(
|
||||
logger2.debug(
|
||||
`Writing a diagnostic for ${language}, but the database at ${databasePath} does not exist yet.`
|
||||
);
|
||||
const tempDiagnosticsPath = getTempDiagnosticPath(config.tempDir, language);
|
||||
const diagnosticPath = writeDiagnosticFile(tempDiagnosticsPath, diagnostic);
|
||||
temporaryDiagnostics.push({ path: diagnosticPath, language });
|
||||
writeTemporaryDiagnosticFile(config.tempDir, language, diagnostic);
|
||||
}
|
||||
}
|
||||
function addNoLanguageDiagnostic(config, diagnostic) {
|
||||
@@ -173020,11 +173018,18 @@ function addNoLanguageDiagnostic(config, diagnostic) {
|
||||
diagnostic
|
||||
);
|
||||
} else {
|
||||
const tempDiagnosticsPath = getTempDiagnosticPath(getTemporaryDirectory());
|
||||
const diagnosticPath = writeDiagnosticFile(tempDiagnosticsPath, diagnostic);
|
||||
temporaryDiagnostics.push({ path: diagnosticPath });
|
||||
writeTemporaryDiagnosticFile(
|
||||
getTemporaryDirectory(),
|
||||
void 0,
|
||||
diagnostic
|
||||
);
|
||||
}
|
||||
}
|
||||
function writeTemporaryDiagnosticFile(tempDir, language, diagnostic) {
|
||||
const tempDiagnosticsPath = getTempDiagnosticPath(tempDir, language);
|
||||
const diagnosticPath = writeDiagnosticFile(tempDiagnosticsPath, diagnostic);
|
||||
temporaryDiagnostics.push({ path: diagnosticPath, language });
|
||||
}
|
||||
function writeDiagnosticFile(diagnosticsPath, diagnostic) {
|
||||
fs7.mkdirSync(diagnosticsPath, { recursive: true });
|
||||
const uniqueSuffix = (diagnosticCounter++).toString();
|
||||
|
||||
@@ -175,11 +175,7 @@ export function addDiagnostic(
|
||||
);
|
||||
|
||||
// Write the diagnostic to a temporary location.
|
||||
const tempDiagnosticsPath = getTempDiagnosticPath(config.tempDir, language);
|
||||
const diagnosticPath = writeDiagnosticFile(tempDiagnosticsPath, diagnostic);
|
||||
|
||||
// Track the temporary file.
|
||||
temporaryDiagnostics.push({ path: diagnosticPath, language });
|
||||
writeTemporaryDiagnosticFile(config.tempDir, language, diagnostic);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -197,14 +193,32 @@ export function addNoLanguageDiagnostic(
|
||||
diagnostic,
|
||||
);
|
||||
} else {
|
||||
const tempDiagnosticsPath = getTempDiagnosticPath(getTemporaryDirectory());
|
||||
const diagnosticPath = writeDiagnosticFile(tempDiagnosticsPath, diagnostic);
|
||||
|
||||
// Track the temporary file.
|
||||
temporaryDiagnostics.push({ path: diagnosticPath });
|
||||
// Write the diagnostic to a temporary location.
|
||||
writeTemporaryDiagnosticFile(
|
||||
getTemporaryDirectory(),
|
||||
undefined,
|
||||
diagnostic,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes {@link diagnostic} for an optional {@link language} to a subdirectory of {@link tempDir}
|
||||
* and tracks it as a diagnostic that was written to a temporary location.
|
||||
*/
|
||||
function writeTemporaryDiagnosticFile(
|
||||
tempDir: string,
|
||||
language: Language | undefined,
|
||||
diagnostic: DiagnosticMessage,
|
||||
) {
|
||||
// Write the diagnostic to a temporary location.
|
||||
const tempDiagnosticsPath = getTempDiagnosticPath(tempDir, language);
|
||||
const diagnosticPath = writeDiagnosticFile(tempDiagnosticsPath, diagnostic);
|
||||
|
||||
// Track the temporary file.
|
||||
temporaryDiagnostics.push({ path: diagnosticPath, language });
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes {@link diagnostic} to a file in {@link diagnosticsPath}.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user