From 6ce04baafb4643f16cebceb53b47a3796efb9a02 Mon Sep 17 00:00:00 2001 From: "Michael B. Gale" Date: Fri, 9 Oct 2026 19:38:43 +0100 Subject: [PATCH] Import `fs` as qualified --- lib/entry-points.js | 22 +++++++++++----------- src/diagnostics.ts | 18 ++++++------------ 2 files changed, 17 insertions(+), 23 deletions(-) diff --git a/lib/entry-points.js b/lib/entry-points.js index 9b4c669f4..124ed3fa4 100644 --- a/lib/entry-points.js +++ b/lib/entry-points.js @@ -172969,7 +172969,7 @@ var jsonschema = __toESM(require_lib2()); var semver5 = __toESM(require_semver2()); // src/diagnostics.ts -var import_fs = require("fs"); +var nodefs = __toESM(require("fs")); var import_path2 = __toESM(require("path")); var temporaryDiagnostics = []; var diagnosticCounter = 0; @@ -172990,7 +172990,7 @@ function getTempDiagnosticPath(tmpDir, language) { function addDiagnostic(config, language, diagnostic) { const logger2 = getActionsLogger(); const databasePath = language ? getCodeQLDatabasePath(config, language) : config.dbLocation; - if ((0, import_fs.existsSync)(databasePath)) { + if (nodefs.existsSync(databasePath)) { writeDiagnostic(config, language, diagnostic); } else { logger2.debug( @@ -173017,7 +173017,7 @@ function addNoLanguageDiagnostic(config, diagnostic) { } } function writeDiagnosticFile(diagnosticsPath, diagnostic) { - (0, import_fs.mkdirSync)(diagnosticsPath, { recursive: true }); + nodefs.mkdirSync(diagnosticsPath, { recursive: true }); const uniqueSuffix = (diagnosticCounter++).toString(); const sanitizedTimestamp = diagnostic.timestamp.replace( /[^a-zA-Z0-9.-]/g, @@ -173027,7 +173027,7 @@ function writeDiagnosticFile(diagnosticsPath, diagnostic) { diagnosticsPath, `codeql-action-${sanitizedTimestamp}-${uniqueSuffix}.json` ); - (0, import_fs.writeFileSync)(jsonPath, JSON.stringify(diagnostic)); + nodefs.writeFileSync(jsonPath, JSON.stringify(diagnostic)); return jsonPath; } function getDatabaseDiagnosticsPath(config, language) { @@ -173052,7 +173052,7 @@ function logTemporaryDiagnostics() { `${num} diagnostic(s) could not be written to the database and will not appear on the Tool Status Page.` ); for (const temporary of temporaryDiagnostics) { - logger2.debug((0, import_fs.readFileSync)(temporary.path, "utf-8")); + logger2.debug(nodefs.readFileSync(temporary.path, "utf-8")); } } } @@ -173066,7 +173066,7 @@ function flushDiagnostics(config) { const directory = getDatabaseDiagnosticsPath(config, temporary.language); const filename = import_path2.default.basename(temporary.path); const destination = import_path2.default.join(directory, filename); - (0, import_fs.renameSync)(temporary.path, destination); + nodefs.renameSync(temporary.path, destination); } temporaryDiagnostics = []; } @@ -180920,7 +180920,7 @@ var artifactLegacy = __toESM(require_artifact_client2()); var core15 = __toESM(require_core()); // node_modules/archiver/lib/core.js -var import_fs2 = require("fs"); +var import_fs = require("fs"); // node_modules/is-stream/index.js function isStream(stream2, { checkOpen = true } = {}) { @@ -183136,7 +183136,7 @@ var Archiver = class extends import_readable_stream2.Transform { data.sourcePath = filepath; task.data = data; this._entriesCount++; - if (data.stats && data.stats instanceof import_fs2.Stats) { + if (data.stats && data.stats instanceof import_fs.Stats) { task = this._updateQueueTaskWithStats(task, data.stats); if (task) { if (data.stats.size) { @@ -183384,7 +183384,7 @@ var Archiver = class extends import_readable_stream2.Transform { callback(); return; } - (0, import_fs2.lstat)( + (0, import_fs.lstat)( task.filepath, function(err, stats) { if (this._state.aborted) { @@ -183446,7 +183446,7 @@ var Archiver = class extends import_readable_stream2.Transform { task.data.type = "file"; task.data.sourceType = "stream"; task.source = new import_lazystream.Readable(function() { - return (0, import_fs2.createReadStream)(task.filepath); + return (0, import_fs.createReadStream)(task.filepath); }); } else if (stats.isDirectory() && this._supportsDirectory) { task.data.name = trailingSlashIt(task.data.name); @@ -183455,7 +183455,7 @@ var Archiver = class extends import_readable_stream2.Transform { task.data.sourceType = "buffer"; task.source = Buffer.concat([]); } else if (stats.isSymbolicLink() && this._supportsSymlink) { - const linkPath = (0, import_fs2.readlinkSync)(task.filepath); + const linkPath = (0, import_fs.readlinkSync)(task.filepath); const dirName = (0, import_path7.dirname)(task.filepath); task.data.type = "symlink"; task.data.linkname = (0, import_path7.relative)( diff --git a/src/diagnostics.ts b/src/diagnostics.ts index f08c83c42..a6d137edf 100644 --- a/src/diagnostics.ts +++ b/src/diagnostics.ts @@ -1,10 +1,4 @@ -import { - existsSync, - mkdirSync, - readFileSync, - renameSync, - writeFileSync, -} from "fs"; +import * as nodefs from "fs"; import path from "path"; import { getTemporaryDirectory } from "./actions-util"; @@ -172,7 +166,7 @@ export function addDiagnostic( // Check that the database exists before writing to it. If the database does not yet exist, // store the diagnostic in memory and write it later. - if (existsSync(databasePath)) { + if (nodefs.existsSync(databasePath)) { writeDiagnostic(config, language, diagnostic); } else { logger.debug( @@ -218,7 +212,7 @@ function writeDiagnosticFile( diagnostic: DiagnosticMessage, ): string { // Create the directory if it doesn't exist yet. - mkdirSync(diagnosticsPath, { recursive: true }); + nodefs.mkdirSync(diagnosticsPath, { recursive: true }); // Include a monotonically increasing suffix to avoid filename collisions // between diagnostics produced within the same millisecond. @@ -234,7 +228,7 @@ function writeDiagnosticFile( `codeql-action-${sanitizedTimestamp}-${uniqueSuffix}.json`, ); - writeFileSync(jsonPath, JSON.stringify(diagnostic)); + nodefs.writeFileSync(jsonPath, JSON.stringify(diagnostic)); return jsonPath; } @@ -281,7 +275,7 @@ export function logTemporaryDiagnostics() { ); for (const temporary of temporaryDiagnostics) { - logger.debug(readFileSync(temporary.path, "utf-8")); + logger.debug(nodefs.readFileSync(temporary.path, "utf-8")); } } } @@ -306,7 +300,7 @@ export function flushDiagnostics(config: Config) { const filename = path.basename(temporary.path); const destination = path.join(directory, filename); - renameSync(temporary.path, destination); + nodefs.renameSync(temporary.path, destination); } // Reset the temporary diagnostics arrays.