import * as fs from "fs/promises";
import * as path from "path";
// Recursive file listing helper
export async function getAllFiles(dir) {
    let results = [];
    try {
        const list = await fs.readdir(dir);
        for (const file of list) {
            const filePath = path.join(dir, file);
            const stat = await fs.stat(filePath);
            if (stat && stat.isDirectory()) {
                results = results.concat(await getAllFiles(filePath));
            }
            else {
                if (file.endsWith(".json")) {
                    results.push(filePath);
                }
            }
        }
    }
    catch (_err) {
        // Directory might not exist or be empty
        console.error(`Warning: Could not read directory ${dir}`);
    }
    return results;
}
