2023-10-31 14:47:59 -04:00
|
|
|
/**
|
2023-10-31 17:38:15 -04:00
|
|
|
* The main entrypoint when using Bun as the runtime
|
2023-10-31 14:47:59 -04:00
|
|
|
*/
|
2023-10-31 17:38:15 -04:00
|
|
|
|
2023-11-10 18:22:09 -05:00
|
|
|
import { getTermios, IRuntime, RunTimeType } from '../common/mod.ts';
|
|
|
|
import BunFFI from './ffi.ts';
|
|
|
|
import BunTerminalIO from './terminal_io.ts';
|
2023-10-31 17:38:15 -04:00
|
|
|
|
2023-11-10 18:22:09 -05:00
|
|
|
process.on('error', async (e) => {
|
|
|
|
(await getTermios()).disableRawMode();
|
|
|
|
console.error(e);
|
|
|
|
process.exit();
|
|
|
|
});
|
|
|
|
|
|
|
|
const BunRuntime: IRuntime = {
|
|
|
|
name: RunTimeType.Bun,
|
|
|
|
ffi: BunFFI,
|
|
|
|
io: BunTerminalIO,
|
|
|
|
onExit: (cb: () => void): void => {
|
|
|
|
process.on('beforeExit', cb);
|
|
|
|
process.on('exit', cb);
|
|
|
|
process.on('SIGINT', cb);
|
|
|
|
},
|
|
|
|
exit: (code?: number) => process.exit(code),
|
2023-11-08 15:53:14 -05:00
|
|
|
};
|
2023-11-10 18:22:09 -05:00
|
|
|
|
|
|
|
export default BunRuntime;
|