diff --git a/node_modules/ignore-walk/lib/index.js b/node_modules/ignore-walk/lib/index.js index 40a0726c3257f..ad3aecc7389c6 100644 --- a/node_modules/ignore-walk/lib/index.js +++ b/node_modules/ignore-walk/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() } @@ -208,15 +209,19 @@ class Walker extends EE { new Walker(this.walkerOpt(entry, opts)).on('done', then).start() } - filterEntry (entry, partial) { + filterEntry (entry, partial, entryBasename) { let included = true // this = /a/b/c // entry = d // parent /a/b sees c/d if (this.parent && this.parent.filterEntry) { - var pt = this.basename + '/' + entry - included = this.parent.filterEntry(pt, partial) + const parentEntry = this.basename + '/' + entry + const parentBasename = entryBasename || entry + included = this.parent.filterEntry(parentEntry, partial, parentBasename) + if (!included && !this.exact) { + return false + } } this.ignoreFiles.forEach(f => { @@ -226,17 +231,28 @@ class Walker extends EE { // so if it's negated, and already included, no need to check // likewise if it's neither negated nor included if (rule.negate !== included) { + const isRelativeRule = entryBasename && rule.globParts.some(part => + part.length <= (part.slice(-1)[0] ? 1 : 2) + ) + // first, match against /foo/bar // then, against foo/bar // then, in the case of partials, match with a / + // then, if also the rule is relative, match against basename const match = rule.match('/' + entry) || rule.match(entry) || - (!!partial && ( + !!partial && ( rule.match('/' + entry + '/') || - rule.match(entry + '/'))) || - (!!partial && rule.negate && ( - rule.match('/' + entry, true) || - rule.match(entry, true))) + rule.match(entry + '/') || + rule.negate && ( + rule.match('/' + entry, true) || + rule.match(entry, true)) || + isRelativeRule && ( + rule.match('/' + entryBasename + '/') || + rule.match(entryBasename + '/') || + rule.negate && ( + rule.match('/' + entryBasename, true) || + rule.match(entryBasename, true)))) if (match) { included = rule.negate diff --git a/node_modules/ignore-walk/package.json b/node_modules/ignore-walk/package.json index 4d9752ae25127..cebd4795f953a 100644 --- a/node_modules/ignore-walk/package.json +++ b/node_modules/ignore-walk/package.json @@ -1,11 +1,11 @@ { "name": "ignore-walk", - "version": "6.0.3", + "version": "6.0.4", "description": "Nested/recursive `.gitignore`/`.npmignore` parsing and filtering.", "main": "lib/index.js", "devDependencies": { "@npmcli/eslint-config": "^4.0.0", - "@npmcli/template-oss": "4.14.1", + "@npmcli/template-oss": "4.19.0", "mutate-fs": "^2.1.1", "tap": "^16.0.1" }, @@ -56,7 +56,7 @@ }, "templateOSS": { "//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.", - "version": "4.14.1", + "version": "4.19.0", "content": "scripts/template-oss", "publish": "true" } diff --git a/package-lock.json b/package-lock.json index 2a4ae8c284533..d0fd84fbe1e1f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7998,9 +7998,9 @@ } }, "node_modules/ignore-walk": { - "version": "6.0.3", - "resolved": "https://registry.npmjs.org/ignore-walk/-/ignore-walk-6.0.3.tgz", - "integrity": "sha512-C7FfFoTA+bI10qfeydT8aZbvr91vAEU+2W5BZUlzPec47oNb07SsOfwYrtxuvOYdUApPP/Qlh4DtAO51Ekk2QA==", + "version": "6.0.4", + "resolved": "https://registry.npmjs.org/ignore-walk/-/ignore-walk-6.0.4.tgz", + "integrity": "sha512-t7sv42WkwFkyKbivUCglsQW5YWMskWtbEf4MNKX5u/CCWHKSPzN4FtBQGsQZgCLbxOzpVlcbWVK5KB3auIOjSw==", "inBundle": true, "dependencies": { "minimatch": "^9.0.0"