#!/usr/bin/env node "use strict"; const fs = require("fs"); const path = require("path"); const { spawnSync } = require("child_process"); const repoRoot = path.resolve(__dirname, ".."); const files = []; collect(path.join(repoRoot, "src")); for (const file of files) { const result = spawnSync(process.execPath, ["--check", file], { cwd: repoRoot, encoding: "utf8", }); if (result.stdout) process.stdout.write(result.stdout); if (result.stderr) process.stderr.write(result.stderr); if (result.status !== 0) process.exit(result.status); } console.log(`Checked ${files.length} CommonJS files.`); function collect(directory) { for (const entry of fs.readdirSync(directory, { withFileTypes: true })) { const fullPath = path.join(directory, entry.name); if (entry.isDirectory()) { collect(fullPath); } else if (entry.isFile() && entry.name.endsWith(".cjs")) { files.push(fullPath); } } }