import fs from "node:fs/promises"; import path from "node:path"; import { spawn } from "node:child_process"; import { fileURLToPath } from "node:url"; const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), ".."); const files = []; async function walk(directory) { for (const entry of await fs.readdir(directory, { withFileTypes: true })) { const target = path.join(directory, entry.name); if (entry.isDirectory() && entry.name !== "vendor") await walk(target); else if (entry.isFile() && target.endsWith(".mjs")) files.push(target); } } await walk(root); for (const file of files) { await new Promise((resolve, reject) => { const child = spawn(process.execPath, ["--check", file], { stdio: "inherit" }); child.once("error", reject); child.once("exit", (code) => code === 0 ? resolve() : reject(new Error(`Syntax check failed: ${file}`))); }); } console.log(`Checked ${files.length} JavaScript modules.`);