mirror of
https://github.com/morluto/rea.git
synced 2026-11-13 18:22:42 +00:00
refactor: prune test-only seams and obsolete helpers (#10275)
This commit is contained in:
1 parent
a8527d43b8
commit
02ebd3e02d
291 files changed
+1882
-1377
No files matched your search
+24
@@ -0,0 +1,24 @@
|
||||
import { open } from "node:fs/promises";
|
||||
|
||||
/** Observe completed writes to a real prepared-image file. */
|
||||
export const hopperImageCopyFileSystem = (
|
||||
destination: string,
|
||||
afterWrite: (bytes: number) => Promise<void>,
|
||||
openFile: typeof open = open,
|
||||
) => ({
|
||||
open: (async (...args: Parameters<typeof open>) => {
|
||||
const handle = await openFile(...args);
|
||||
if (args[0] === destination) {
|
||||
const writeFile = handle.writeFile.bind(handle);
|
||||
handle.writeFile = (async (
|
||||
...writeArgs: Parameters<typeof writeFile>
|
||||
) => {
|
||||
await writeFile(...writeArgs);
|
||||
const data = writeArgs[0];
|
||||
if (!Buffer.isBuffer(data)) throw new Error("Expected a buffer write");
|
||||
await afterWrite(data.length);
|
||||
}) as typeof handle.writeFile;
|
||||
}
|
||||
return handle;
|
||||
}) as typeof open,
|
||||
});
|
||||
Reference in new issue
Block a user