Include mkdirSync in try/catch

This commit is contained in:
Michael B. Gale 2023-10-05 13:48:56 +01:00
parent a144bf5d7f
commit 3b2fee487e
No known key found for this signature in database
GPG key ID: FF5E2765BD00628F
3 changed files with 12 additions and 12 deletions

6
lib/diagnostics.js generated
View file

@ -33,10 +33,10 @@ exports.makeDiagnostic = makeDiagnostic;
function addDiagnostic(config, language, diagnostic) {
const logger = (0, logging_1.getActionsLogger)();
const diagnosticsPath = path_1.default.resolve((0, util_1.getCodeQLDatabasePath)(config, language), "diagnostic", "codeql-action");
// Create the directory if it doesn't exist yet.
(0, fs_1.mkdirSync)(diagnosticsPath, { recursive: true });
const jsonPath = path_1.default.resolve(diagnosticsPath, `codeql-action-${diagnostic.timestamp}.json`);
try {
// Create the directory if it doesn't exist yet.
(0, fs_1.mkdirSync)(diagnosticsPath, { recursive: true });
const jsonPath = path_1.default.resolve(diagnosticsPath, `codeql-action-${diagnostic.timestamp}.json`);
(0, fs_1.writeFileSync)(jsonPath, JSON.stringify(diagnostic));
}
catch (err) {