Skip to content

Commit

Permalink
Do not emit 'match' events for ignored items
Browse files Browse the repository at this point in the history
Fix #194
  • Loading branch information
isaacs committed Jul 2, 2015
1 parent 9439afd commit f5878af
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions glob.js
Expand Up @@ -57,6 +57,7 @@ var ownProp = common.ownProp
var inflight = require('inflight')
var util = require('util')
var childrenIgnored = common.childrenIgnored
var isIgnored = common.isIgnored

var once = require('once')

Expand Down Expand Up @@ -432,6 +433,9 @@ Glob.prototype._emitMatch = function (index, e) {
if (this.matches[index][e])
return

if (isIgnored(this, e))
return

if (this.paused) {
this._emitQueue.push([index, e])
return
Expand Down
5 changes: 5 additions & 0 deletions test/ignore.js
Expand Up @@ -44,6 +44,8 @@ cases.forEach(function (c, i) {
if (cwd)
name += ' cwd=' + cwd

var matches = []

var opt = { ignore: ignore }
if (cwd)
opt.cwd = cwd
Expand All @@ -53,9 +55,12 @@ cases.forEach(function (c, i) {
if (er)
throw er
t.same(res.sort(), expect, 'async')
t.same(matches.sort(), expect, 'match events')
res = glob.sync(pattern, opt)
t.same(res.sort(), expect, 'sync')
t.end()
}).on('match', function (p) {
matches.push(p)
})
})
})

0 comments on commit f5878af

Please sign in to comment.