Closed wmertens closed 4 years ago
Hi, I'm not sure I fully understand.
Yes, you're right. On Linux, where the recursive watch is not supported natively, and when the recursive
option is specified it will traverse all its sub-directories despite the filter function behaves.
So it's the same to filter inside the callback
function filter(name) {}
watch('./', { recursive: true }, function(evt, name) {
if (filter(name)) {
// action
}
})
Ok, so my request is to not watch paths that will be filtered out anyway.
And I proposed the -1 to indicate that a path has to be watched despite being filtered, although I'm not sure if that is a useful feature.
That's an optimization. PRs welcome :)
when "manually" recursing with a filter specified, I think node-watch watches paths that are always ignored.
I believe this test doesn't test what is says it tests: https://github.com/yuanchuan/node-watch/blob/3ad4726be15bd2475a6863345b8afc4229e47de8/test/test.js#L381
I think node-watch watches all paths recursively and then only filters the change events.
I imagine there may be a semantics issue around ignoring changes to parent directories but not children. Perhaps
filter
should be allowed to return-1
for "ignore but watch children", and falsy for "always ignore".Also, if this works, it may be more efficient to "manually" recursively watch, so perhaps then it should not use native recursive watching when
filter
is specified?