| 1 | import { main } from "./main.js"; |
| 2 | |
| 3 | // The bundle targets Node.js 22; on an older one, say so instead of failing somewhere obscure. |
| 4 | if (Number(process.versions.node.split(".")[0]) < 22) { |
| 5 | process.stderr.write(`error: diffinery needs Node.js 22 or later (this is ${process.version}). Reinstall with: curl -fsSL https://diffinery.com/install | bash\n`); |
| 6 | process.exit(1); |
| 7 | } |
| 8 | |
| 9 | // EPIPE when piping into `head` and similar should end quietly. |
| 10 | process.stdout.on("error", (e: NodeJS.ErrnoException) => { |
| 11 | if (e.code === "EPIPE") process.exit(0); |
| 12 | }); |
| 13 | |
| 14 | main(process.argv.slice(2)).then( |
| 15 | (code) => { |
| 16 | process.exitCode = code; |
| 17 | }, |
| 18 | (e: unknown) => { |
| 19 | process.stderr.write(`error: ${String(e)}\n`); |
| 20 | process.exitCode = 1; |
| 21 | }, |
| 22 | ); |