import { spawn } from 'node:child_process';

const run = (cmd, args, opts = {}) =>
  new Promise((resolve, reject) => {
    const p = spawn(cmd, args, { stdio: 'inherit', ...opts });
    p.on('exit', (code) => (code === 0 ? resolve() : reject(new Error(`${cmd} exited with ${code}`))));
  });

const main = async () => {
  // Test syntax checks
  await run('bash', ['-lc', 'find src -name "*.js" -print0 | xargs -0 -n1 node --check'], {
    cwd: process.cwd(),
  });

  console.log('Smoke test passed: syntax checks OK');
};

main().catch((err) => {
  console.error('Smoke test failed:', err.message);
  process.exit(1);
});
