Skip to content

Commit 5ad657c

Browse files
renovate[bot]scagood
andauthoredJan 22, 2024
chore: update dependency minimatch to v9 (#167)
* chore: update dependency minimatch to v9 * fix: add "allowWindowsEscape" to Minimatch options * fix: Convert all patterns to posix from win32 in Minimatch --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Sebastian Good <2230835+scagood@users.noreply.github.com>
1 parent fc77da2 commit 5ad657c

File tree

3 files changed

+21
-5
lines changed

3 files changed

+21
-5
lines changed
 

‎lib/util/check-restricted.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,12 @@ class Restriction {
3939
const negate = raw[0] === "!" && raw[1] !== "("
4040
const pattern = negate ? raw.slice(1) : raw
4141
const absolute = path.isAbsolute(pattern)
42-
const matcher = new Minimatch(pattern, { dot: true })
42+
43+
const posix = pattern.replace(/\\/g, "/")
44+
const matcher = new Minimatch(posix, {
45+
allowWindowsEscape: true,
46+
dot: true,
47+
})
4348
return { absolute, matcher, negate }
4449
})
4550

‎lib/util/get-convert-path.js

+14-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*/
55
"use strict"
66

7-
const Minimatch = require("minimatch").Minimatch
7+
const { Minimatch } = require("minimatch")
88

99
/**
1010
* @param {any} x - An any value.
@@ -45,6 +45,17 @@ function toStringArray(x) {
4545
return []
4646
}
4747

48+
/**
49+
* @param {string} pattern
50+
* @return {Minimatch}
51+
*/
52+
function makeMatcher(pattern) {
53+
const posix = pattern.replace(/\\/g, "/")
54+
return new Minimatch(posix, {
55+
allowWindowsEscape: true,
56+
})
57+
}
58+
4859
/**
4960
* Creates the function which checks whether a file path is matched with the given pattern or not.
5061
*
@@ -53,8 +64,8 @@ function toStringArray(x) {
5364
* @returns {function} Created predicate function.
5465
*/
5566
function createMatch(includePatterns, excludePatterns) {
56-
const include = includePatterns.map(pattern => new Minimatch(pattern))
57-
const exclude = excludePatterns.map(pattern => new Minimatch(pattern))
67+
const include = includePatterns.map(makeMatcher)
68+
const exclude = excludePatterns.map(makeMatcher)
5869

5970
return filePath =>
6071
include.some(m => m.match(filePath)) &&

‎package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"ignore": "^5.2.4",
2323
"is-builtin-module": "^3.2.1",
2424
"is-core-module": "^2.12.1",
25-
"minimatch": "^3.1.2",
25+
"minimatch": "^9.0.0",
2626
"semver": "^7.5.3"
2727
},
2828
"devDependencies": {

0 commit comments

Comments
 (0)
Please sign in to comment.