* Wrap an InMemoryFs in a Proxy that hides `readFileBytes`, forcing every * caller down the fallback path. Delegates everything else.
(seed: Record<string, string>)
| 17 | * caller down the fallback path. Delegates everything else. |
| 18 | */ |
| 19 | function createLegacyFs(seed: Record<string, string>): IFileSystem { |
| 20 | const inner = new InMemoryFs(seed); |
| 21 | return new Proxy(inner, { |
| 22 | get(target, prop, receiver) { |
| 23 | if (prop === "readFileBytes") return undefined; |
| 24 | const value = Reflect.get(target, prop, receiver); |
| 25 | // Methods need to keep their `this` bound to the inner instance. |
| 26 | return typeof value === "function" ? value.bind(target) : value; |
| 27 | }, |
| 28 | has(target, prop) { |
| 29 | if (prop === "readFileBytes") return false; |
| 30 | return Reflect.has(target, prop); |
| 31 | }, |
| 32 | }) as IFileSystem; |
| 33 | } |
| 34 | |
| 35 | describe("readFileBytes back-compat fallback", () => { |
| 36 | it("commands work against a custom IFileSystem missing readFileBytes", async () => { |
no outgoing calls
no test coverage detected
searching dependent graphs…