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-29 16:09:58 -05:00
|
|
|
import { IRuntime, RunTimeType } from '../common/runtime.ts';
|
2024-07-09 10:23:25 -04:00
|
|
|
import TerminalIO from '../tsx/terminal_io.ts';
|
|
|
|
import FileIO from '../tsx/file_io.ts';
|
2023-10-31 17:38:15 -04:00
|
|
|
|
2024-07-05 15:51:30 -04:00
|
|
|
import process from 'node:process';
|
2024-06-26 15:45:33 -04:00
|
|
|
|
2024-07-05 15:51:30 -04:00
|
|
|
/**
|
|
|
|
* The Bun Runtime implementation
|
|
|
|
*/
|
2023-11-10 18:22:09 -05:00
|
|
|
const BunRuntime: IRuntime = {
|
|
|
|
name: RunTimeType.Bun,
|
2024-07-09 10:23:25 -04:00
|
|
|
file: FileIO,
|
|
|
|
term: TerminalIO,
|
2023-11-16 13:00:02 -05:00
|
|
|
onEvent: (eventName: string, handler) => process.on(eventName, handler),
|
2023-11-10 18:22:09 -05:00
|
|
|
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;
|