#!/usr/bin/env node

const path = require('path');
const { spawnSync } = require('child_process');

const installScript = path.join(__dirname, '..', 'install.js');
const args = process.argv.slice(2);
const upgradeCommands = new Set(['upgrade', 'update', '--update', '--check-updates']);
const invoke = upgradeCommands.has(args[0]) ? 'gw' : 'orchestra';
const result = spawnSync(process.execPath, [installScript, `--invoke=${invoke}`, ...args], {
  stdio: 'inherit',
});
process.exit(result.status ?? 0);
