check:browser-gates-guarded names its detector files by path

internal/lib/browser-gates.mjs holds the regex that looks for a playwright
import, so the check read it as an import once the file was tracked. The guard
and the two detectors are excluded by path, so a real import added to one of
them still fails.
This commit is contained in:
Doxa Maps 2026-09-28 07:12:04 +00:00
parent 78eb6bdcb8
commit 462f553442

View file

@ -22,9 +22,12 @@ if (process.argv.includes('--list')) {
console.error(`${names.length} script(s) launch a browser: run each as internal/browser-slot.sh bun run <name>`)
process.exit(0)
}
// Files that NAME the import pattern in a regex without importing playwright (the guard itself, and the
// detectors that look for it). Listed by path, not skipped by content, so a real import added to one fails.
const DETECTORS = new Set(['internal/lib/playwright-guarded.mjs', 'internal/check-browser-gates-guarded.mjs', 'internal/lib/browser-gates.mjs'])
const DIRECT = /from\s+['"]playwright['"]|import\(\s*['"]playwright['"]\s*\)|require\(\s*['"]playwright['"]\s*\)/
const files = execFileSync('git', ['ls-files', '--', 'internal', 'plugin-designs'], { cwd: ROOT, encoding: 'utf8' })
.split('\n').filter((f) => /\.(mjs|js|cjs)$/.test(f) && f !== 'internal/lib/playwright-guarded.mjs' && f !== 'internal/check-browser-gates-guarded.mjs' && f !== 'internal/run-parallel.mjs')
.split('\n').filter((f) => /\.(mjs|js|cjs)$/.test(f) && !DETECTORS.has(f))
const bad = []
for (const f of files) {
const code = readFileSync(resolve(ROOT, f), 'utf8').replace(/\/\*[\s\S]*?\*\//g, '').replace(/^\s*\/\/.*$/gm, '')