From 3f73dff942809eec082bed0edcbcf66dab7715e7 Mon Sep 17 00:00:00 2001 From: divyanshujethi Date: Sat, 7 Nov 2026 07:01:44 +0530 Subject: [PATCH 1/2] fix(cli): support directory scanning in scan and compliance commands without EISDIR crash --- src/cli.ts | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 53 insertions(+), 3 deletions(-) diff --git a/src/cli.ts b/src/cli.ts index cf4e598..af4243a 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -1,5 +1,5 @@ #!/usr/bin/env node -import { existsSync, readFileSync, writeFileSync } from "node:fs"; +import { existsSync, readFileSync, writeFileSync, statSync, readdirSync } from "node:fs"; import { platform } from "node:os"; import { join } from "node:path"; import { loadConfig, parseCustomPatterns } from "./config.js"; @@ -687,7 +687,32 @@ Direct verification link: process.exit(1); } - const content = readFileSync(targetFile, "utf8"); + let content = ""; + if (statSync(targetFile).isDirectory()) { + const files: string[] = []; + const walk = (dir: string) => { + try { + for (const entry of readdirSync(dir, { withFileTypes: true })) { + if (entry.name === ".git" || entry.name === "node_modules" || entry.name === "dist") continue; + const full = join(dir, entry.name); + if (entry.isDirectory()) walk(full); + else if (entry.isFile()) files.push(full); + } + } catch {} + }; + walk(targetFile); + content = files + .map((f) => { + try { + return `// FILE: ${f}\n` + readFileSync(f, "utf8"); + } catch { + return ""; + } + }) + .join("\n\n"); + } else { + content = readFileSync(targetFile, "utf8"); + } const isJson = args.includes("--json"); const includeRaw = args.includes("--include-raw"); @@ -962,7 +987,32 @@ Direct verification link: process.exit(1); } - const content = readFileSync(targetFile, "utf8"); + let content = ""; + if (statSync(targetFile).isDirectory()) { + const files: string[] = []; + const walk = (dir: string) => { + try { + for (const entry of readdirSync(dir, { withFileTypes: true })) { + if (entry.name === ".git" || entry.name === "node_modules" || entry.name === "dist") continue; + const full = join(dir, entry.name); + if (entry.isDirectory()) walk(full); + else if (entry.isFile()) files.push(full); + } + } catch {} + }; + walk(targetFile); + content = files + .map((f) => { + try { + return `// FILE: ${f}\n` + readFileSync(f, "utf8"); + } catch { + return ""; + } + }) + .join("\n\n"); + } else { + content = readFileSync(targetFile, "utf8"); + } const scan = engine.scanAndRedact(content); const { ComplianceEngine } = await import("./compliance.js"); From 3b57f825859ce72a33c13ae3c3b71ad5ccffd817 Mon Sep 17 00:00:00 2001 From: divyanshujethi Date: Sat, 7 Nov 2026 07:02:58 +0530 Subject: [PATCH 2/2] style: format cli.ts according to biome rules --- src/cli.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/cli.ts b/src/cli.ts index af4243a..59f7d9f 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -1,5 +1,5 @@ #!/usr/bin/env node -import { existsSync, readFileSync, writeFileSync, statSync, readdirSync } from "node:fs"; +import { existsSync, readFileSync, readdirSync, statSync, writeFileSync } from "node:fs"; import { platform } from "node:os"; import { join } from "node:path"; import { loadConfig, parseCustomPatterns } from "./config.js"; @@ -693,7 +693,8 @@ Direct verification link: const walk = (dir: string) => { try { for (const entry of readdirSync(dir, { withFileTypes: true })) { - if (entry.name === ".git" || entry.name === "node_modules" || entry.name === "dist") continue; + if (entry.name === ".git" || entry.name === "node_modules" || entry.name === "dist") + continue; const full = join(dir, entry.name); if (entry.isDirectory()) walk(full); else if (entry.isFile()) files.push(full); @@ -704,7 +705,7 @@ Direct verification link: content = files .map((f) => { try { - return `// FILE: ${f}\n` + readFileSync(f, "utf8"); + return `// FILE: ${f}\n${readFileSync(f, "utf8")}`; } catch { return ""; } @@ -993,7 +994,8 @@ Direct verification link: const walk = (dir: string) => { try { for (const entry of readdirSync(dir, { withFileTypes: true })) { - if (entry.name === ".git" || entry.name === "node_modules" || entry.name === "dist") continue; + if (entry.name === ".git" || entry.name === "node_modules" || entry.name === "dist") + continue; const full = join(dir, entry.name); if (entry.isDirectory()) walk(full); else if (entry.isFile()) files.push(full); @@ -1004,7 +1006,7 @@ Direct verification link: content = files .map((f) => { try { - return `// FILE: ${f}\n` + readFileSync(f, "utf8"); + return `// FILE: ${f}\n${readFileSync(f, "utf8")}`; } catch { return ""; }