Skip to content

Commit

Permalink
fix: disallow child unignoring parent directory ignore (#116)
Browse files Browse the repository at this point in the history
Closes: npm/cli#7007
  • Loading branch information
mohd-akram committed Nov 28, 2023
1 parent 12a7c00 commit 0bb0972
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/index.js
Expand Up @@ -217,6 +217,9 @@ class Walker extends EE {
if (this.parent && this.parent.filterEntry) {
var pt = this.basename + '/' + entry
included = this.parent.filterEntry(pt, partial)
if (!included && partial) {
return false
}
}

this.ignoreFiles.forEach(f => {
Expand Down
30 changes: 30 additions & 0 deletions test/preserve-ignores.js
@@ -0,0 +1,30 @@
'use strict'

var walk = require('../lib/index.js')
const { resolve } = require('path')
const path = resolve(__dirname, 'fixtures')

// set the ignores just for this test
var c = require('./common.js')
c.ignores({
'.ignore': ['*', '!/c', '!/d'],
'c/.ignore': ['!*', '.ignore'], // unignore everything
})

// the only files we expect to see
var expected = []

const t = require('tap')

t.test('sync', t => {
t.same(walk.sync({
path,
ignoreFiles: ['.ignore'],
}), expected)
t.end()
})

t.test('async', t => walk({
path,
ignoreFiles: ['.ignore'],
}, (er, result) => t.same(result, expected)))

0 comments on commit 0bb0972

Please sign in to comment.