stat.js 759 B

1234567891011121314151617181920212223242526272829303132
  1. var glob = require('../')
  2. var test = require('tap').test
  3. var path = require('path')
  4. test('stat all the things', function(t) {
  5. var g = new glob.Glob('a/*abc*/**', { stat: true, cwd: __dirname })
  6. var matches = []
  7. g.on('match', function(m) {
  8. matches.push(m)
  9. })
  10. var stats = []
  11. g.on('stat', function(m) {
  12. stats.push(m)
  13. })
  14. g.on('end', function(eof) {
  15. stats = stats.sort()
  16. matches = matches.sort()
  17. eof = eof.sort()
  18. t.same(stats, matches)
  19. t.same(eof, matches)
  20. var cache = Object.keys(this.statCache)
  21. t.same(cache.map(function (f) {
  22. return path.relative(__dirname, f)
  23. }).sort(), matches)
  24. cache.forEach(function(c) {
  25. t.equal(typeof this.statCache[c], 'object')
  26. }, this)
  27. t.end()
  28. })
  29. })