mirror of
https://github.com/github/codeql-action.git
synced 2026-10-30 17:39:50 +00:00
Refactor writeTemporaryDiagnosticFile out of add[NoLanguage]Diagnostic
This commit is contained in:
@@ -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