Skip to content

Commit 5e7e910

Browse files
authored
refactor: replace minimatch with picomatch (#1847)
1 parent b9db8e9 commit 5e7e910

File tree

4 files changed

+43
-28
lines changed

4 files changed

+43
-28
lines changed

package-lock.json

Lines changed: 35 additions & 22 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,9 @@
125125
"markdown-it-github-alerts": "^1.0.0",
126126
"markdown-it-task-lists": "^2.1.1",
127127
"mime-types": "^3.0.1",
128-
"minimatch": "^10.0.3",
129128
"moment": "^2.30.1",
130129
"mustache": "^4.2.0",
130+
"picomatch": "^4.0.3",
131131
"url-parse": "^1.5.10",
132132
"vanilla-picker": "^2.12.3",
133133
"yargs": "^18.0.0"

src/lib/fileList.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import fsOperation from "fileSystem";
22
import toast from "components/toast";
3-
import { minimatch } from "minimatch";
3+
import picomatch from "picomatch/posix";
44
import Url from "utils/Url";
55
import { addedFolder } from "./openFolder";
66
import settings from "./settings";
@@ -310,8 +310,10 @@ async function createChildTree(parent, item, root) {
310310

311311
parent.children.push(file);
312312
if (isDirectory) {
313-
const ignore = !!settings.value.excludeFolders.find((folder) =>
314-
minimatch(Url.join(file.path, ""), folder, { matchBase: true }),
313+
const ignore = picomatch.isMatch(
314+
Url.join(file.path, ""),
315+
settings.value.excludeFolders,
316+
{ matchBase: true },
315317
);
316318
if (ignore) return;
317319

src/sidebarApps/searchInFiles/worker.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import "core-js/stable";
2-
import { minimatch } from "minimatch";
2+
import picomatch from "picomatch/posix";
33

44
const resolvers = {};
55

@@ -237,7 +237,7 @@ function Skip({ exclude, include }) {
237237
function test(file) {
238238
if (!file.path) return false;
239239
const match = (pattern) =>
240-
minimatch(file.path, pattern, { matchBase: true });
240+
picomatch.isMatch(file.path, pattern, { matchBase: true });
241241
return excludeFiles.some(match) || !includeFiles.some(match);
242242
}
243243

0 commit comments

Comments
 (0)