diff --git a/lib/index.js b/lib/index.js index 91fbe36..ad3aecc 100644 --- a/lib/index.js +++ b/lib/index.js @@ -22,6 +22,7 @@ class Walker extends EE { this.result = this.parent ? this.parent.result : new Set() this.entries = null this.sawError = false + this.exact = opts.exact } sort (a, b) { @@ -164,7 +165,7 @@ class Walker extends EE { } else { // is a directory if (dir) { - this.walker(entry, { isSymbolicLink }, then) + this.walker(entry, { isSymbolicLink, exact: file || this.filterEntry(entry + '/') }, then) } else { then() } @@ -218,7 +219,7 @@ class Walker extends EE { const parentEntry = this.basename + '/' + entry const parentBasename = entryBasename || entry included = this.parent.filterEntry(parentEntry, partial, parentBasename) - if (!included && partial) { + if (!included && !this.exact) { return false } } diff --git a/test/nested-ignores.js b/test/nested-ignores.js index b937437..42648bc 100644 --- a/test/nested-ignores.js +++ b/test/nested-ignores.js @@ -26,9 +26,6 @@ var expected = [ 'c/d/c/ccc', 'c/d/d/ccc', 'd/c/h/.dch', - 'h/c/d/.hcd', - 'h/c/d/dch', - 'h/c/d/ddd', 'h/c/d/hcd', ] diff --git a/test/preserve-ignores.js b/test/preserve-ignores.js index e0e316c..2514940 100644 --- a/test/preserve-ignores.js +++ b/test/preserve-ignores.js @@ -7,12 +7,25 @@ const path = resolve(__dirname, 'fixtures') // set the ignores just for this test var c = require('./common.js') c.ignores({ - '.ignore': ['*', '!/c', '!/d'], + '.ignore': ['*', '!/c/d', '!/d/c', '!/d/d/', '!/d/h/h'], 'c/.ignore': ['!*', '.ignore'], // unignore everything + 'd/c/.ignore': ['!h', '!cc*', '.ignore'], // unignore directory + 'd/d/.ignore': ['!h/', '!cc*', '.ignore'], // unignore directory with slash + 'd/h/h/.ignore': ['!dd*', '.ignore'], // unignore files }) // the only files we expect to see -var expected = [] +var expected = [ + 'd/c/h/ccc', + 'd/c/h/ccd', + 'd/c/h/cch', + 'd/d/h/ccc', + 'd/d/h/ccd', + 'd/d/h/cch', + 'd/h/h/ddc', + 'd/h/h/ddd', + 'd/h/h/ddh', +] const t = require('tap')