#!/usr/bin/env node
"use strict";

const { execFileSync } = require("child_process");
const fs = require("fs");
const path = require("path");

const binName = process.platform === "win32" ? "remit.exe" : "remit";
const binPath = path.join(__dirname, binName);

if (!fs.existsSync(binPath)) {
  console.error("remit binary not found. Run: npx @remit-md/cli postinstall");
  console.error("Or download from https://github.com/remit-md/remit-cli/releases");
  process.exit(1);
}

try {
  const result = execFileSync(binPath, process.argv.slice(2), {
    stdio: "inherit",
  });
} catch (err) {
  process.exit(err.status || 1);
}
