37 lines
857 B
TypeScript
Executable File
37 lines
857 B
TypeScript
Executable File
#!/usr/bin/env bun
|
|
|
|
import { fileURLToPath } from "node:url";
|
|
import { dirname } from "node:path";
|
|
import { runCli } from "./cli/runner.js";
|
|
|
|
process.stdout.on("error", (err: any) => {
|
|
if (err?.code === "EPIPE") process.exit(0);
|
|
});
|
|
process.stderr.on("error", (err: any) => {
|
|
if (err?.code === "EPIPE") process.exit(0);
|
|
});
|
|
|
|
const entryFile = fileURLToPath(import.meta.url);
|
|
const appRoot = dirname(dirname(entryFile));
|
|
|
|
const result = await runCli(process.argv.slice(2), {
|
|
appRoot,
|
|
entryFile,
|
|
});
|
|
|
|
try {
|
|
if (result.stdout) process.stdout.write(result.stdout);
|
|
} catch (err: any) {
|
|
if (err?.code !== "EPIPE") throw err;
|
|
}
|
|
|
|
try {
|
|
if (result.stderr) {
|
|
process.stderr.write(`${result.stderr}${result.stderr.endsWith("\n") ? "" : "\n"}`);
|
|
}
|
|
} catch (err: any) {
|
|
if (err?.code !== "EPIPE") throw err;
|
|
}
|
|
|
|
process.exitCode = result.exitCode;
|