glob-fs icon indicating copy to clipboard operation
glob-fs copied to clipboard

Multiple calls to readdirSync adds to the returned array

Open stubar opened this issue 6 years ago • 5 comments

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.

stubar avatar Mar 06 '18 12:03 stubar

Same issue for not specifying options.

laseryuan avatar Apr 16 '18 08:04 laseryuan

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

mntmn avatar Apr 16 '18 19:04 mntmn

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

mistic100 avatar May 21 '18 07:05 mistic100

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

ferdinandyb avatar Sep 20 '18 07:09 ferdinandyb

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

marrowleaves avatar Sep 30 '18 04:09 marrowleaves