micromatch / glob-fs

file globbing for node.js. speedy and powerful alternative to node-glob. This library is experimental and does not work on windows!
http://jonschlinkert.github.io/glob-fs
MIT License
55 stars 17 forks source link

Multiple calls to readdirSync adds to the returned array #25

Open stubar opened 6 years ago

stubar commented 6 years ago

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.

laseryuan commented 6 years ago

Same issue for not specifying options.

mntmn commented 6 years ago

Ran into the same issue which caused a security problem (files returned that should not have been).

mistic100 commented 6 years ago

Encountered this problem as well, unfortunately I had to switch to https://github.com/isaacs/node-glob

ferdinandyb commented 5 years ago

can confirm :( https://stackoverflow.com/questions/52414684/unexpected-behaviour-of-glob-fs-glob-readdirsync

marrowleaves commented 5 years ago

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(..)