Use fs.watch but ignore node_modules

荒凉一梦 提交于 2020-07-10 08:47:08

问题


I am looking at the docs for fs.watch

https://nodejs.org/docs/latest/api/fs.html#fs_fs_watch_filename_options_listener

How can I watch all files in the current directory, but ignore node_modules?


回答1:


Doesn't look like it's possible. Just take a look at the path in the listener and do nothing if it starts with 'node_modules'.

It can't be that much of a performance hit, unless you're constantly updating modules while node is running, which would be a little strange.



来源:https://stackoverflow.com/questions/48054139/use-fs-watch-but-ignore-node-modules

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!