oac.js 681 B

123456789101112131415161718192021
  1. #!/usr/bin/env node
  2. 'use strict';
  3. const { execFileSync } = require('child_process');
  4. const path = require('path');
  5. const fs = require('fs');
  6. const cliDist = path.join(__dirname, '..', 'packages', 'cli', 'dist', 'index.js');
  7. if (!fs.existsSync(cliDist)) {
  8. console.error('Error: OAC CLI not built yet. Run: npm run build -w packages/cli');
  9. process.exit(1);
  10. }
  11. // Re-exec the bundled CLI on the SAME Node binary that is running this shim, so
  12. // `oac` works wherever `npm i -g` could install it — no Bun, no PATH lookup.
  13. try {
  14. execFileSync(process.execPath, [cliDist, ...process.argv.slice(2)], { stdio: 'inherit' });
  15. } catch (err) {
  16. process.exitCode = err.status ?? 1;
  17. }