#!/usr/bin/env node
const { execFileSync } = require('child_process');
const os = require('os');
const path = require('path');

const platform = os.platform();

let binaryPath = '';

if (platform === 'darwin') {
  binaryPath = path.join(__dirname, 'bin', 'recodepush-macos');
} else if (platform === 'linux') {
  binaryPath = path.join(__dirname, 'bin', 'recodepush-linux');
} else if (platform === 'win32') {
  binaryPath = path.join(__dirname, 'bin', 'recodepush-win.exe');
} else {
  console.error('Unsupported platform: ' + platform);
  process.exit(1);
}

try {
  execFileSync(binaryPath, process.argv.slice(2), { stdio: 'inherit' });
} catch (err) {
  console.error('Error executing binary:', err);
  process.exit(1);
}
