Skip to content

Commit c7f915f

Browse files
committed
refactor!: replace anymatch with native path.matchesGlob
1 parent 92a0d61 commit c7f915f

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
"unstorage": "node jiti src/cli.ts"
3434
},
3535
"dependencies": {
36-
"anymatch": "^3.1.3",
3736
"destr": "^2.0.5",
3837
"node-fetch-native": "^1.6.7",
3938
"ofetch": "^1.4.1",

src/drivers/fs.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { existsSync, promises as fsp, Stats } from "node:fs";
2-
import { resolve, relative, join } from "node:path";
2+
import { resolve, relative, join, matchesGlob } from "node:path";
33
import type { FSWatcher, ChokidarOptions } from "chokidar";
4-
import anymatch from "anymatch";
54
import {
65
createError,
76
createRequiredError,
@@ -33,9 +32,14 @@ export default defineDriver((userOptions: FSStorageOptions = {}) => {
3332
}
3433

3534
const base = resolve(userOptions.base);
36-
const ignore = (anymatch as any)(
37-
userOptions.ignore || ["**/node_modules/**", "**/.git/**"]
38-
);
35+
36+
const ignorePatterns = userOptions.ignore || [
37+
"**/node_modules/**",
38+
"**/.git/**",
39+
];
40+
const ignore = (path: string) => {
41+
return ignorePatterns.some((pattern) => matchesGlob(path, pattern));
42+
};
3943

4044
const r = (key: string) => {
4145
if (PATH_TRAVERSE_RE.test(key)) {

0 commit comments

Comments
 (0)