The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
// runner.ts
import { spawn } from "child_process";
const command: string = process.argv[2];
if (!command) {
console.error("Please provide a command name.");
process.exit(1);
}
const scriptPath = `./scripts/${command}.${
command === "send-emails" ? "tsx" : "ts"
}`;
// Get all arguments after the command (e.g., --truncate)
const scriptArgs = process.argv.slice(3);
const child = spawn(
"tsx",
["--stack-size=5120000", scriptPath, ...scriptArgs],
{
stdio: "inherit", // This pipes stdout/stderr directly to the parent process
shell: true, // Allows running commands as if in a shell
env: {
...process.env,
NODE_OPTIONS: [
process.env.NODE_OPTIONS,
"--conditions=react-server",
"--import=./scripts/runtime/async-local-storage.cjs",
]
.filter(Boolean)
.join(" "),
},
},
);
child.on("error", (error) => {
console.error(`Error executing script: ${error.message}`);
process.exit(1);
});
child.on("exit", (code) => {
process.exit(code ?? 0);
});