2023-11-16 16:00:03 -05:00
|
|
|
import { IFileIO } from '../common/runtime.ts';
|
2023-11-16 11:10:33 -05:00
|
|
|
import { appendFile } from 'node:fs/promises';
|
2023-11-13 15:33:56 -05:00
|
|
|
|
2023-11-16 16:00:03 -05:00
|
|
|
const BunFileIO: IFileIO = {
|
2023-11-13 15:33:56 -05:00
|
|
|
openFile: async (path: string): Promise<string> => {
|
|
|
|
const file = await Bun.file(path);
|
|
|
|
return await file.text();
|
|
|
|
},
|
2023-11-16 11:10:33 -05:00
|
|
|
appendFile: async function (path: string, contents: string): Promise<void> {
|
2023-11-16 13:00:02 -05:00
|
|
|
return await appendFile(path, contents);
|
|
|
|
},
|
2023-11-21 15:14:08 -05:00
|
|
|
saveFile: async function (path: string, contents: string): Promise<void> {
|
|
|
|
await Bun.write(path, contents);
|
|
|
|
return;
|
|
|
|
},
|
2023-11-13 15:33:56 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
export default BunFileIO;
|