How to detect directory deletions using node.js watch() function

Viewed 25

I have an app that watches for file changes inside a directory using the node.js watch() function. But my problem emerges when the user deletes that directory. In this situation, the watch() function alerts nothing.

The only solution I have found is to add another watch() function to the parent of that directory. It will alert whether any of its child directories have been modified or not. But I don't think it will be the best solution for this problem because if I have 50 folders, I have to add another 50 'watch()' functions to their parent directories.

0 Answers
Related