import { walkSync } from "../fs/walk.ts";
const ROOT = new URL("../", import.meta.url);const SKIP = [/(test|bench|\/_|\\_|testdata|version.ts)/];const DECLARATION = "// This module is browser compatible.";
function isBrowserCompatible(filePath: string): boolean { const command = new Deno.Command(Deno.execPath(), { args: [ "check", "--config", "browser-compat.tsconfig.json", filePath, ], }); const { success } = command.outputSync(); return success;}
function hasBrowserCompatibleComment(path: string): boolean { const output = Deno.readTextFileSync(path); return output.includes(DECLARATION);}
const maybeBrowserCompatibleFiles: string[] = [];
for (const { path } of walkSync(ROOT, { exts: [".ts"], skip: SKIP })) { if (isBrowserCompatible(path) && !hasBrowserCompatibleComment(path)) { maybeBrowserCompatibleFiles.push(path); }}
if (maybeBrowserCompatibleFiles.length) { console.log( `The following files are likely browser-compatible and can have the "${DECLARATION}" comment added:`, ); maybeBrowserCompatibleFiles.forEach((path, index) => console.log(`${index + 1}. ${path}`) );}