paulmillr / readdirp

Recursive version of fs.readdir with streaming api.
https://paulmillr.com
MIT License
382 stars 53 forks source link

directoryFilter should probably be logic AND, not OR #84

Closed silverwind closed 5 years ago

silverwind commented 5 years ago
# create three test files and dirs
$ mkdir -p dirs/{foo,bar,baz} && touch dirs/{foo,bar,baz}/file

# one filter works as expected, returning two dirs
$ node -e 'require("readdirp")("dirs", {directoryFilter: ["!foo"]}).on("data", entry => console.log(entry.path))'
bar/file
baz/file

# adding a second filter returns all three dirs while only one is expected 
$ node -e 'require("readdirp")("dirs", {directoryFilter: ["!foo", "!bar"]}).on("data", entry => console.log(entry.path))'
bar/file
baz/file
foo/file

Could it be that those filters act like logically OR instead of AND?