fs-monkey
fs-monkey copied to clipboard
Support for Promises
I'm using the patchFS method in combination with unionfs / memfs, and while I get the expected result when using Sync / callback style methods, the fs.promises.X methods seem to be untouched. I'm guessing this is an oversight since the patching code ignores the promises object.
Example:
const Fs = require("fs");
const {ufs} = require("unionfs");
const {vol} = require("memfs");
const {patchFs} = require("fs-monkey");
const MockedFs = {"foo.bar": ""};
vol.fromJSON(MockedFs);
ufs.use({...require("fs")}).use(vol);
patchFs(ufs);
Fs.accessSync("foo.bar") // Undefined, aka accessible
Fs.promises.access("foo.bar").then(console.log).catch(console.error) // Fails, foo.bar not found
ufs.promises.access("foo.bar").then(console.log).catch(console.error) // As expected, doesnt error (Accessible)
You can use my fork @aleung/fs-monkey temporary until #217 got merged and published.