()
| 36 | } |
| 37 | |
| 38 | async function main() { |
| 39 | const args = process.argv.slice(2); |
| 40 | const normalizedArgs = args[0] === "--" ? args.slice(1) : args; |
| 41 | const jsonOutput = normalizedArgs.includes("--json"); |
| 42 | const positionalArgs = normalizedArgs.filter((arg) => arg !== "--json"); |
| 43 | const inputPath = positionalArgs[0]; |
| 44 | if (!inputPath) { |
| 45 | console.error( |
| 46 | "Usage: bun run check:hyperframe-html [--json] <path-to-html>\nExample: bun run check:hyperframe-html core/src/tests/broken-video.html", |
| 47 | ); |
| 48 | process.exit(2); |
| 49 | } |
| 50 | |
| 51 | const resolvedPath = path.resolve(process.cwd(), inputPath); |
| 52 | if (!fs.existsSync(resolvedPath)) { |
| 53 | console.error(`File not found: ${resolvedPath}`); |
| 54 | process.exit(2); |
| 55 | } |
| 56 | |
| 57 | const html = fs.readFileSync(resolvedPath, "utf-8"); |
| 58 | const result = await lintHyperframeHtml(html, { filePath: resolvedPath }); |
| 59 | |
| 60 | if (jsonOutput) { |
| 61 | console.log(JSON.stringify(result, null, 2)); |
| 62 | process.exit(result.ok ? 0 : 1); |
| 63 | } |
| 64 | |
| 65 | if (result.ok) { |
| 66 | console.log(formatHumanOutput(result, resolvedPath)); |
| 67 | process.exit(0); |
| 68 | } |
| 69 | |
| 70 | console.error(formatHumanOutput(result, resolvedPath)); |
| 71 | process.exit(1); |
| 72 | } |
| 73 | |
| 74 | main(); |
no test coverage detected