Something went wrong. Try again.
Identities for entities did.bot
agent llm did
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859// Shared helpers for the site's own test scripts. Kept dependency-light// (linkedom for HTML parsing is the one exception, since hand-rolling that// with regexes is how a link checker grows its own bugs).import { readFileSync, readdirSync, statSync } from "node:fs";import { dirname, join, resolve } from "node:path";import { fileURLToPath } from "node:url";import { parseHTML } from "linkedom";
export const here = dirname(fileURLToPath(import.meta.url));export const siteRoot = resolve(here, "..");export const repoRoot = resolve(siteRoot, "..");export const distDir = join(siteRoot, "dist");
export function requireDist() { try { statSync(distDir); } catch { throw new Error( `${distDir} does not exist — run "npm run build" in site/ before the tests`, ); }}
export function walkFiles(dir = distDir, extension = ".html") { const out = []; for (const entry of readdirSync(dir, { withFileTypes: true })) { const full = join(dir, entry.name); if (entry.isDirectory()) { out.push(...walkFiles(full, extension)); } else if (entry.name.endsWith(extension)) { out.push(full); } } return out;}
export function walkHtmlFiles(dir = distDir) { return walkFiles(dir, ".html");}
export function loadDocument(path) { const html = readFileSync(path, "utf8"); return parseHTML(html).document;}
let failures = 0;export function fail(message) { failures += 1; console.error(`FAIL: ${message}`);}
export function report(name) { if (failures > 0) { console.error(`\n${name}: ${failures} failure(s)`); process.exit(1); } console.log(`${name}: ok`);}