Set up basic functionality for bun
This commit is contained in:
parent
fba91bde10
commit
103cd1ecf6
4
justfile
4
justfile
@ -9,6 +9,10 @@ deno-lint:
|
||||
# Code linting with bun
|
||||
bun-lint:
|
||||
|
||||
# Run with bun
|
||||
bun-run:
|
||||
bun run ./src/scroll.ts
|
||||
|
||||
# Run with deno
|
||||
deno-run:
|
||||
deno run --allow-all --allow-ffi --deny-net --deny-hrtime --unstable ./src/scroll.ts
|
15
src/bun/index.ts
Normal file
15
src/bun/index.ts
Normal file
@ -0,0 +1,15 @@
|
||||
/**
|
||||
* The main entrypoint when using Deno as the runtime
|
||||
*/
|
||||
export async function main(): Promise<number> {
|
||||
const decoder = new TextDecoder();
|
||||
for await (const chunk of Bun.stdin.stream()) {
|
||||
const char = String(decoder.decode(chunk)).trim();
|
||||
|
||||
if (char === 'q') {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
@ -15,10 +15,11 @@ export enum RunTime {
|
||||
let RUNTIME = RunTime.Unknown;
|
||||
if ('Deno' in globalThis) {
|
||||
RUNTIME = RunTime.Deno;
|
||||
const { main } = await import('./deno/index.ts');
|
||||
await main();
|
||||
}
|
||||
if ('Bun' in globalThis) {
|
||||
RUNTIME = RunTime.Bun;
|
||||
}
|
||||
|
||||
const { main } = await import(`./${RUNTIME}/index.ts`);
|
||||
await main();
|
||||
})();
|
||||
|
Loading…
Reference in New Issue
Block a user