yuanchuan / node-watch

A wrapper and enhancements for fs.watch
https://npm.im/node-watch
MIT License
339 stars 44 forks source link

Use async fs functions #124

Closed ianshade closed 1 year ago

ianshade commented 2 years ago

This is my attempt at getting rid of synchronous fs calls, which is supposed to fix https://github.com/yuanchuan/node-watch/issues/107. I too noticed that the event loop was blocked in some scenarios, for example when a high number of files was being created in watched folder in a short period of time. After these changes it performs much better and doesn't block.

I decided to use fs-extra for the promise-based functions but that might have been unnecessary because that library supports only node >= 12, so node-watch doesn't really gain anything by using it.

But are you okay with dropping support for some older versions of node at all?

I could do the following things if node >= 12 was too high:

I think that would also mean recursive: true would always be natively supported.

yuanchuan commented 2 years ago

Hi @ianshade, thank you so much for the effort!

I would like to use latest JS features but the current plan is to keep this project change as less as possible. I'm not sure if the change will bring other issues, which is acceptable. I just don't have much time to continue to test and fix them.

I'll hold this pr for some time!

yuanchuan commented 1 year ago

I need to close this PR. Thanks again!