mirror of
https://github.com/github/codeql-action.git
synced 2026-11-06 21:19:42 +00:00
Clean up path functions in diagnostics.ts and add some tests
This commit is contained in:
34
lib/entry-points.js
generated
34
lib/entry-points.js
generated
@@ -172991,6 +172991,11 @@ var semver4 = __toESM(require_semver2());
|
||||
// src/diagnostics.ts
|
||||
var fs7 = __toESM(require("fs"));
|
||||
var import_path2 = __toESM(require("path"));
|
||||
var TEMP_DIAGNOSTIC_DIR_NAME = "codeql-action-temp-diagnostics";
|
||||
var CODEQL_ACTION_DIAGNOSTIC_SUBDIR_PARTS = [
|
||||
"diagnostic",
|
||||
"codeql-action"
|
||||
];
|
||||
var temporaryDiagnostics = [];
|
||||
var diagnosticCounter = 0;
|
||||
function makeDiagnostic(id, name, data = void 0) {
|
||||
@@ -173000,15 +173005,25 @@ function makeDiagnostic(id, name, data = void 0) {
|
||||
source: { ...data?.source, id, name }
|
||||
};
|
||||
}
|
||||
function getTempDiagnosticPath(tmpDir, language) {
|
||||
const root = import_path2.default.join(tmpDir, "codeql-action-temp-diagnostics");
|
||||
return getDiagnosticsPath(root, language);
|
||||
function getLanguageDiagnosticsPath(basePath, language) {
|
||||
return import_path2.default.resolve(
|
||||
basePath,
|
||||
language,
|
||||
...CODEQL_ACTION_DIAGNOSTIC_SUBDIR_PARTS
|
||||
);
|
||||
}
|
||||
function getDiagnosticsPath(basePath, language) {
|
||||
function getTempDiagnosticsRoot(tmpDir) {
|
||||
return import_path2.default.resolve(tmpDir, TEMP_DIAGNOSTIC_DIR_NAME);
|
||||
}
|
||||
function getTempLanguageDiagnosticsPath(tmpDir, language) {
|
||||
const root = getTempDiagnosticsRoot(tmpDir);
|
||||
if (language !== void 0) {
|
||||
return import_path2.default.resolve(basePath, language, "diagnostic", "codeql-action");
|
||||
return getLanguageDiagnosticsPath(root, language);
|
||||
}
|
||||
return import_path2.default.resolve(basePath, "diagnostic", "codeql-action");
|
||||
return import_path2.default.resolve(root, ...CODEQL_ACTION_DIAGNOSTIC_SUBDIR_PARTS);
|
||||
}
|
||||
function getDatabaseDiagnosticsPath(config, language) {
|
||||
return getLanguageDiagnosticsPath(config.dbLocation, language);
|
||||
}
|
||||
function addDiagnostic(config, language, diagnostic, logger2 = getActionsLogger()) {
|
||||
const databasePath = language ? getCodeQLDatabasePath(config, language) : config.dbLocation;
|
||||
@@ -173043,7 +173058,7 @@ function addNoLanguageDiagnostic(config, diagnostic, logger2 = getActionsLogger(
|
||||
}
|
||||
}
|
||||
function writeTemporaryDiagnosticFile(logger2, tempDir, language, diagnostic) {
|
||||
const tempDiagnosticsPath = getTempDiagnosticPath(tempDir, language);
|
||||
const tempDiagnosticsPath = getTempLanguageDiagnosticsPath(tempDir, language);
|
||||
try {
|
||||
const diagnosticPath = writeDiagnosticFile(tempDiagnosticsPath, diagnostic);
|
||||
temporaryDiagnostics.push({ path: diagnosticPath, language });
|
||||
@@ -173069,9 +173084,6 @@ function writeDiagnosticFile(diagnosticsPath, diagnostic) {
|
||||
fs7.writeFileSync(jsonPath, JSON.stringify(diagnostic));
|
||||
return jsonPath;
|
||||
}
|
||||
function getDatabaseDiagnosticsPath(config, language) {
|
||||
return getDiagnosticsPath(config.dbLocation, language);
|
||||
}
|
||||
function writeDiagnostic(action, config, language, diagnostic) {
|
||||
const diagnosticsPath = getDatabaseDiagnosticsPath(config, language);
|
||||
try {
|
||||
@@ -187059,7 +187071,7 @@ async function generateFailedSarif(logger2, features, config, category, checkout
|
||||
codeql
|
||||
);
|
||||
if (databasePath === void 0 || !exportDiagnosticsEnabled) {
|
||||
let diagnosticDir = getTempDiagnosticPath(
|
||||
let diagnosticDir = getTempDiagnosticsRoot(
|
||||
config.tempDir
|
||||
);
|
||||
if (!exportDiagnosticsEnabled || !fs31.existsSync(diagnosticDir)) {
|
||||
|
||||
Reference in New Issue
Block a user