Skip to content

chore: update dependency minimatch to v9 #167

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion lib/util/check-restricted.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,12 @@ class Restriction {
const negate = raw[0] === "!" && raw[1] !== "("
const pattern = negate ? raw.slice(1) : raw
const absolute = path.isAbsolute(pattern)
const matcher = new Minimatch(pattern, { dot: true })

const posix = pattern.replace(/\\/g, "/")
const matcher = new Minimatch(posix, {
allowWindowsEscape: true,
dot: true,
})
return { absolute, matcher, negate }
})

Expand Down
17 changes: 14 additions & 3 deletions lib/util/get-convert-path.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/
"use strict"

const Minimatch = require("minimatch").Minimatch
const { Minimatch } = require("minimatch")

/**
* @param {any} x - An any value.
Expand Down Expand Up @@ -45,6 +45,17 @@ function toStringArray(x) {
return []
}

/**
* @param {string} pattern
* @return {Minimatch}
*/
function makeMatcher(pattern) {
const posix = pattern.replace(/\\/g, "/")
return new Minimatch(posix, {
allowWindowsEscape: true,
})
}

/**
* Creates the function which checks whether a file path is matched with the given pattern or not.
*
Expand All @@ -53,8 +64,8 @@ function toStringArray(x) {
* @returns {function} Created predicate function.
*/
function createMatch(includePatterns, excludePatterns) {
const include = includePatterns.map(pattern => new Minimatch(pattern))
const exclude = excludePatterns.map(pattern => new Minimatch(pattern))
const include = includePatterns.map(makeMatcher)
const exclude = excludePatterns.map(makeMatcher)

return filePath =>
include.some(m => m.match(filePath)) &&
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"ignore": "^5.2.4",
"is-builtin-module": "^3.2.1",
"is-core-module": "^2.12.1",
"minimatch": "^3.1.2",
"minimatch": "^9.0.0",
"semver": "^7.5.3"
},
"devDependencies": {
Expand Down