tschaub / mock-fs

Configurable mock for the fs module
https://npmjs.org/package/mock-fs
Other
907 stars 85 forks source link

Add support for fs.watch(). #300

Closed dpryden closed 4 years ago

dpryden commented 4 years ago

This support currently only works for Node v10 and newer, since the fs_event_wrap native binding is lazy-loaded and thus can be pre-patched before first use.

To make this robust enough to actually use, it may be necessary to also add in monkeypatching of the fs.watch endpoint.

The tests are incomplete; mainly just enough to demonstrate that this works as a proof of concept.

tschaub commented 4 years ago

Thanks for the work on this, @dpryden. I didn't intend to close this pull request – forgot that that happens automatically when changing default branches. We can still use these commits if someone else wants to take up this work. Or feel free to open a new pull request (you should be able to git pull --rebase upstream main && git push --force origin fs-watch depending on how you have named your remotes).

dpryden commented 4 years ago

OK, I rebased (and fixed a minor merge conflict) and created #308 as a replacement. Thanks for reminding me about this PR @tschaub !

I no longer have a pressing need for this change but I'm happy to help move it forward. However, realistically I think it might be easiest to wait until mock-fs is willing to drop support for old versions of Node... and I have no idea when that might happen, or if it's worth investing more effort in this now.