@@ -38175,7 +38175,7 @@ __export(cli_executor_exports, {
3817538175 validateCommandExists: () => validateCommandExists
3817638176});
3817738177import { execFile } from "child_process";
38178- import { existsSync as existsSync2, readdirSync, readFileSync as readFileSync2 } from "fs";
38178+ import { existsSync as existsSync2, readdirSync, readFileSync as readFileSync2, statSync } from "fs";
3817938179import { basename, delimiter as delimiter4, dirname as dirname2, isAbsolute as isAbsolute2, join as join4 } from "path";
3818038180import { homedir } from "os";
3818138181import { promisify } from "util";
@@ -38223,6 +38223,13 @@ function discoverVsCodeCodeQLDistribution(candidateStorageRoots) {
3822338223 }
3822438224 return void 0;
3822538225}
38226+ function isRegularFile(filePath) {
38227+ try {
38228+ return statSync(filePath).isFile();
38229+ } catch {
38230+ return false;
38231+ }
38232+ }
3822638233function discoverFromDistributionJson(codeqlStorage) {
3822738234 try {
3822838235 const jsonPath = join4(codeqlStorage, "distribution.json");
@@ -38236,7 +38243,7 @@ function discoverFromDistributionJson(codeqlStorage) {
3823638243 "codeql",
3823738244 CODEQL_BINARY_NAME
3823838245 );
38239- if (existsSync2 (binaryPath)) {
38246+ if (isRegularFile (binaryPath)) {
3824038247 logger.debug(`Discovered CLI via distribution.json (folderIndex=${data.folderIndex})`);
3824138248 return binaryPath;
3824238249 }
@@ -38247,9 +38254,9 @@ function discoverFromDistributionJson(codeqlStorage) {
3824738254function discoverFromDistributionScan(codeqlStorage) {
3824838255 try {
3824938256 const entries = readdirSync(codeqlStorage, { withFileTypes: true });
38250- const distDirs = entries.filter((e) => e.isDirectory() && /^distribution\d* $/.test(e.name)).map((e) => ({
38257+ const distDirs = entries.filter((e) => e.isDirectory() && /^distribution\d+ $/.test(e.name)).map((e) => ({
3825138258 name: e.name,
38252- num: parseInt(e.name.replace("distribution", "") || "0" , 10)
38259+ num: parseInt(e.name.replace("distribution", ""), 10)
3825338260 })).sort((a, b) => b.num - a.num);
3825438261 for (const dir of distDirs) {
3825538262 const binaryPath = join4(
@@ -38258,7 +38265,7 @@ function discoverFromDistributionScan(codeqlStorage) {
3825838265 "codeql",
3825938266 CODEQL_BINARY_NAME
3826038267 );
38261- if (existsSync2 (binaryPath)) {
38268+ if (isRegularFile (binaryPath)) {
3826238269 logger.debug(`Discovered CLI via distribution scan: ${dir.name}`);
3826338270 return binaryPath;
3826438271 }
@@ -38267,13 +38274,13 @@ function discoverFromDistributionScan(codeqlStorage) {
3826738274 }
3826838275 return void 0;
3826938276}
38270- function resolveCodeQLBinary() {
38277+ function resolveCodeQLBinary(candidateStorageRoots ) {
3827138278 if (resolvedBinaryResult !== void 0) {
3827238279 return resolvedBinaryResult;
3827338280 }
3827438281 const envPath = process.env.CODEQL_PATH;
3827538282 if (!envPath) {
38276- const discovered = discoverVsCodeCodeQLDistribution();
38283+ const discovered = discoverVsCodeCodeQLDistribution(candidateStorageRoots );
3827738284 if (discovered) {
3827838285 resolvedCodeQLDir = dirname2(discovered);
3827938286 resolvedBinaryResult = "codeql";
@@ -60648,7 +60655,7 @@ var codeqlGenerateQueryHelpTool = {
6064860655};
6064960656
6065060657// src/tools/codeql/list-databases.ts
60651- import { existsSync as existsSync6, readdirSync as readdirSync3, readFileSync as readFileSync5, statSync as statSync2 } from "fs";
60658+ import { existsSync as existsSync6, readdirSync as readdirSync3, readFileSync as readFileSync5, statSync as statSync3 } from "fs";
6065260659import { join as join8 } from "path";
6065360660
6065460661// src/lib/discovery-config.ts
@@ -60712,7 +60719,7 @@ async function discoverDatabases(baseDirs, language) {
6071260719 for (const entry of entries) {
6071360720 const entryPath = join8(baseDir, entry);
6071460721 try {
60715- if (!statSync2 (entryPath).isDirectory()) {
60722+ if (!statSync3 (entryPath).isDirectory()) {
6071660723 continue;
6071760724 }
6071860725 } catch {
@@ -60801,7 +60808,7 @@ function registerListDatabasesTool(server) {
6080160808}
6080260809
6080360810// src/tools/codeql/list-mrva-run-results.ts
60804- import { existsSync as existsSync7, readdirSync as readdirSync4, readFileSync as readFileSync6, statSync as statSync3 } from "fs";
60811+ import { existsSync as existsSync7, readdirSync as readdirSync4, readFileSync as readFileSync6, statSync as statSync4 } from "fs";
6080560812import { join as join9 } from "path";
6080660813init_logger();
6080760814var NUMERIC_DIR_PATTERN = /^\d+$/;
@@ -60821,7 +60828,7 @@ async function discoverMrvaRunResults(resultsDirs, runId) {
6082160828 for (const entry of entries) {
6082260829 const entryPath = join9(dir, entry);
6082360830 try {
60824- if (!statSync3 (entryPath).isDirectory()) {
60831+ if (!statSync4 (entryPath).isDirectory()) {
6082560832 continue;
6082660833 }
6082760834 } catch {
@@ -60866,7 +60873,7 @@ function discoverRepoResults(runPath) {
6086660873 }
6086760874 const ownerPath = join9(runPath, ownerEntry);
6086860875 try {
60869- if (!statSync3 (ownerPath).isDirectory()) {
60876+ if (!statSync4 (ownerPath).isDirectory()) {
6087060877 continue;
6087160878 }
6087260879 } catch {
@@ -60881,7 +60888,7 @@ function discoverRepoResults(runPath) {
6088160888 for (const repoEntry of repoEntries) {
6088260889 const repoPath = join9(ownerPath, repoEntry);
6088360890 try {
60884- if (!statSync3 (repoPath).isDirectory()) {
60891+ if (!statSync4 (repoPath).isDirectory()) {
6088560892 continue;
6088660893 }
6088760894 } catch {
@@ -60988,7 +60995,7 @@ function registerListMrvaRunResultsTool(server) {
6098860995}
6098960996
6099060997// src/tools/codeql/list-query-run-results.ts
60991- import { existsSync as existsSync8, readdirSync as readdirSync5, readFileSync as readFileSync7, statSync as statSync4 } from "fs";
60998+ import { existsSync as existsSync8, readdirSync as readdirSync5, readFileSync as readFileSync7, statSync as statSync5 } from "fs";
6099260999import { join as join10 } from "path";
6099361000init_logger();
6099461001var QUERY_RUN_DIR_PATTERN = /^(.+\.ql)-(.+)$/;
@@ -61037,7 +61044,7 @@ async function discoverQueryRunResults(resultsDirs, filter) {
6103761044 for (const entry of entries) {
6103861045 const entryPath = join10(dir, entry);
6103961046 try {
61040- if (!statSync4 (entryPath).isDirectory()) {
61047+ if (!statSync5 (entryPath).isDirectory()) {
6104161048 continue;
6104261049 }
6104361050 } catch {
@@ -62091,7 +62098,7 @@ function registerQuickEvaluateTool(server) {
6209162098
6209262099// src/tools/codeql/read-database-source.ts
6209362100var import_adm_zip = __toESM(require_adm_zip(), 1);
62094- import { existsSync as existsSync11, readdirSync as readdirSync6, readFileSync as readFileSync10, statSync as statSync5 } from "fs";
62101+ import { existsSync as existsSync11, readdirSync as readdirSync6, readFileSync as readFileSync10, statSync as statSync6 } from "fs";
6209562102import { join as join14, resolve as resolve7 } from "path";
6209662103import { fileURLToPath as fileURLToPath2 } from "url";
6209762104init_logger();
@@ -62110,7 +62117,7 @@ function toFilesystemPath(uri) {
6211062117function* walkDirectory(dir, base = dir) {
6211162118 for (const entry of readdirSync6(dir)) {
6211262119 const fullPath = join14(dir, entry);
62113- if (statSync5 (fullPath).isDirectory()) {
62120+ if (statSync6 (fullPath).isDirectory()) {
6211462121 yield* walkDirectory(fullPath, base);
6211562122 } else {
6211662123 yield fullPath.slice(base.length).replace(/\\/g, "/").replace(/^\//, "");
0 commit comments