Reputation: 374
What is the defference between methods of node.js
file system watching:
watch(filename,[, options],(filename) => {} )
(node-watch package)fs.watch(filename[, options][, listener])
fs.watchFile(filename[, options], listener)
(add more if any)
Upvotes: 3
Views: 2652
Reputation: 1485
I was looking for info on this exact question and came across this post.
fs.watch()
fs.watchFile()
node-watch()
I haven't used node-watch myself, but, by looking at it, I can see it extends fs.watch() and adds recursive functionality. fs.watch() allows you to watch a directory for changes, but to watch all directories below would require separate calls. If I had to guess, (I've not tried it) these might be the same:
fs.watch(./project)
fs.watch(./project/assets)
fs.watch(./project/lib)
Or
node-watch(./project, { recursive: true })
Upvotes: 10