#!/usr/bin/env node import { main } from './cli.ts'; // The executable entry point, in every launch mode this tool has: // // * `bundle …` / `node dist/main.js …` — an ordinary CLI. // * `--vfs-load=` — node runs the mounted package's // `main`, which is this file, out of the archive. // * the SEA container, whose bootstrap mounts its own tail and then requires // the package inside it, landing here. // // In all three, `process.argv` is [runtime, entry, ...userArgs], so the user's // arguments always start at index 2. // // Nothing but argv handling lives here. `cli.ts` returns an exit code rather // than exiting, so it stays callable in-process — by a test, or by a host that // wants the commands without a subprocess — and the one place that turns a code // into an exit is this file. // A reader that stops early — `bundle verify --json x | head` — closes the pipe // under us. That is the reader being done, not a failure worth a stack trace. for (const stream of [process.stdout, process.stderr]) { stream.on('error', (err: NodeJS.ErrnoException) => { if (err.code === 'EPIPE') process.exit(process.exitCode ?? 0); throw err; }); } process.exitCode = await main(process.argv.slice(2));