import { spawnSync } from "node:child_process";
import path from "node:path";
import { fileURLToPath } from "node:url";

const scriptsDir = path.dirname(fileURLToPath(import.meta.url));
const repoRoot = path.join(scriptsDir, "..");
const tsx = path.join(repoRoot, "node_modules", ".bin", "tsx");
const tsconfig = path.join(scriptsDir, "tsconfig.smoke.json");
const smokeScript = path.join(scriptsDir, "smoke-extractors.ts");

const result = spawnSync(
  tsx,
  ["--tsconfig", tsconfig, smokeScript, ...process.argv.slice(2)],
  { cwd: repoRoot, stdio: "inherit", env: process.env },
);

process.exit(result.status ?? 1);
