async.js icon indicating copy to clipboard operation
async.js copied to clipboard

Broken behaviour in glob()

Open aflatter opened this issue 14 years ago • 2 comments

glob finds files that should not match my pattern. Interesting enough, this happens only on the first level.

xy:/tmp/foo$ ls -R .
.:
test  test.js

./test:
dir1  file1.foo  file2.foo  file5.bar

./test/dir1:
file3.foo  file4.bar

xy:/tmp/foo$ cat test.js
var sys   = require('sys'),
    async = require('asyncjs');

async.glob(__dirname + '/test/*/*.foo').toArray(function(err, files) {
  sys.puts(sys.inspect(files));               
});

xy:/tmp/foo$ node test.js
[ { path: '/tmp/foo/test/file1.foo', name: 'file1.foo' }
, { path: '/tmp/foo/test/file5.bar', name: 'file5.bar' }
, { path: '/tmp/foo/test/file2.foo', name: 'file2.foo' }
, { path: '/tmp/foo/test/dir1/file3.foo'
  , name: 'file3.foo'
  , stat: { ... }
  }
]

aflatter avatar Jan 24 '11 15:01 aflatter

You might think about just using https://github.com/isaacs/node-glob/

aflatter avatar Jan 24 '11 16:01 aflatter

Stange. Thanks for the bug report

fjakobs avatar Jan 25 '11 19:01 fjakobs