fs-monkey icon indicating copy to clipboard operation
fs-monkey copied to clipboard

Support for Promises

Open kinsi55 opened this issue 5 years ago • 1 comments

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)

kinsi55 avatar Jun 26 '20 15:06 kinsi55

You can use my fork @aleung/fs-monkey temporary until #217 got merged and published.

aleung avatar Feb 09 '21 11:02 aleung