UNPKG

scai

Version:

> **AI-powered CLI for local code analysis, commit message suggestions, and natural-language queries.** 100% local, private, GDPR-friendly, made in Denmark/EU with ❤️.

30 lines (29 loc) 899 B
import fs from "fs/promises"; import path from "path"; export async function resolveTargetsToFiles(targets, exts) { const files = []; for (const target of targets) { const stat = await fs.stat(target); if (stat.isDirectory()) { files.push(...await collectFilesRecursive(target, exts)); } else { files.push(target); } } return files; } async function collectFilesRecursive(dir, exts) { const entries = await fs.readdir(dir, { withFileTypes: true }); const files = []; for (const entry of entries) { const fullPath = path.join(dir, entry.name); if (entry.isDirectory()) { files.push(...await collectFilesRecursive(fullPath, exts)); } else if (!exts || exts.includes(path.extname(entry.name))) { files.push(fullPath); } } return files; }