const { spawn } = require("child_process");
const { existsSync } = require("fs");
const path = require("path");
const binName = process.platform === "win32" ? "lagrange.exe" : "lagrange";
const binPath = path.join(__dirname, "bin", binName);
if (!existsSync(binPath)) {
console.error("create-lagrange: binary not found at", binPath);
console.error(" Re-run: npm install create-lagrange");
console.error(" Or install via cargo: cargo install lagrange-library");
process.exit(1);
}
const userArgs = process.argv.slice(2);
const child = spawn(binPath, ["init", ...userArgs], {
stdio: "inherit",
});
child.on("exit", (code) => process.exit(code ?? 1));