glob-fs
glob-fs copied to clipboard
Multiple calls to readdirSync adds to the returned array
If I call globFs.readdirSync(path, {cwd: '/'})
multiple times I get a different array each time. The file list is being added to the last response each time.
Note I'm using the cwd param because I'm passing in absolute paths.
Same issue for not specifying options.
Ran into the same issue which caused a security problem (files returned that should not have been).
Encountered this problem as well, unfortunately I had to switch to https://github.com/isaacs/node-glob
can confirm :( https://stackoverflow.com/questions/52414684/unexpected-behaviour-of-glob-fs-glob-readdirsync
A workaround is to create a new instance of the Glob
object each time you match a pattern, like:
const glob = require('glob-fs')
glob().use(..).readdir(..)