#!/usr/bin/env node
const { spawnSync } = require("node:child_process");
const path = require("node:path");

if (process.platform !== "win32") {
  console.error("regen-mde installer is only available on Windows.");
  process.exit(1);
}

const root = path.resolve(__dirname, "..");
const script = path.join(root, "installer", "install-regen-mde.ps1");
const result = spawnSync("powershell.exe", [
  "-NoProfile",
  "-ExecutionPolicy",
  "Bypass",
  "-File",
  script,
  "-PackageRoot",
  root,
  ...process.argv.slice(2),
], {
  stdio: "inherit",
  cwd: root,
  windowsHide: true,
});

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