import { spawn } from 'node:child_process'; import path from 'node:path'; import { fileURLToPath } from 'node:url'; const appRoot = path.resolve(fileURLToPath(new URL('..', import.meta.url))); const cargo = process.platform === 'win32' ? 'cargo.exe' : 'cargo'; const child = spawn( cargo, [ 'run', '--manifest-path', 'src-tauri/Cargo.toml', '--', ...process.argv.slice(2), ], { cwd: appRoot, stdio: 'inherit', }, ); for (const signal of ['SIGINT', 'SIGTERM']) { process.on(signal, () => { child.kill(signal); }); } child.on('exit', (code, signal) => { if (signal) { process.exit(1); } process.exit(code ?? 0); });