scroll/src/bun/mod.ts

30 lines
677 B
JavaScript

/**
* The main entrypoint when using Bun as the runtime
*/
import { getTermios, IRuntime, RunTimeType } from '../common/mod.ts';
import BunFFI from './ffi.ts';
import BunTerminalIO from './terminal_io.ts';
import BunFileIO from './file_io.ts';
process.on('error', async (e) => {
(await getTermios()).disableRawMode();
console.error(e);
process.exit();
});
const BunRuntime: IRuntime = {
name: RunTimeType.Bun,
file: BunFileIO,
ffi: BunFFI,
term: BunTerminalIO,
onExit: (cb: () => void): void => {
process.on('beforeExit', cb);
process.on('exit', cb);
process.on('SIGINT', cb);
},
exit: (code?: number) => process.exit(code),
};
export default BunRuntime;