Incognito-Wiki/scripts/check-rendered-output.mjs
msa46 bcb8dcfe2a
Some checks are pending
Deploy to GitHub Pages / build (push) Waiting to run
Deploy to GitHub Pages / deploy (push) Blocked by required conditions
fix: resolve final Starlight migration review
2026-08-02 18:59:28 +02:00

26 lines
1 KiB
JavaScript

import { resolve } from 'node:path';
import { pathToFileURL } from 'node:url';
import { checkRenderedOutput } from './lib/rendered-output.mjs';
async function main() {
const distRoot = process.argv[2] ?? 'dist';
const result = await checkRenderedOutput({ distRoot });
const issues = [
...result.headingIssues.map(({ file, h1Count }) => `${file} contains ${h1Count} H1 headings; expected exactly 1`),
...result.unpublishedPaths.map((path) => `unpublished to-be-studied path reached built output: ${path}`),
];
if (issues.length > 0) {
throw new Error(`Rendered-output check failed with ${issues.length} issue(s):\n${issues.map((issue) => `- ${issue}`).join('\n')}`);
}
console.log(`Rendered-output check passed: ${result.htmlFilesChecked} published pages, exactly one H1 each, no to-be-studied paths.`);
}
const invokedPath = process.argv[1] ? pathToFileURL(resolve(process.argv[1])).href : '';
if (invokedPath === import.meta.url) {
main().catch((error) => {
console.error(error.message);
process.exitCode = 1;
});
}