Skip to content

Commit fd43c6c

Browse files
author
repo-visualizer
committed
fix: update micromatch glob matching
- match folders that start with . - remove leading ./ when glob matching fixes #35
1 parent 62c798d commit fd43c6c

File tree

2 files changed

+31
-6
lines changed

2 files changed

+31
-6
lines changed

index.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18498,7 +18498,14 @@ var import_micromatch = __toModule(require_micromatch());
1849818498
var shouldExcludePath = (path, pathsToIgnore, globsToIgnore) => {
1849918499
if (!path)
1850018500
return false;
18501-
return pathsToIgnore.has(path) || globsToIgnore.some((glob) => glob && (0, import_micromatch.isMatch)(path, glob));
18501+
return pathsToIgnore.has(path) || globsToIgnore.some((glob) => glob && (0, import_micromatch.isMatch)(processPath(path), glob, {
18502+
dot: true
18503+
}));
18504+
};
18505+
var processPath = (path) => {
18506+
if (path.startsWith("./"))
18507+
return path.substring(2);
18508+
return path;
1850218509
};
1850318510

1850418511
// src/process-dir.js

src/should-exclude-path.ts

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,29 @@
1-
import { isMatch } from 'micromatch';
1+
import { isMatch } from "micromatch";
22

33
/**
44
* True if path is excluded by either the path or glob criteria.
55
* path may be to a directory or individual file.
66
*/
7-
export const shouldExcludePath = (path: string, pathsToIgnore: Set<string>, globsToIgnore: string[]): boolean => {
8-
if (!path) return false
7+
export const shouldExcludePath = (
8+
path: string,
9+
pathsToIgnore: Set<string>,
10+
globsToIgnore: string[]
11+
): boolean => {
12+
if (!path) return false;
913

10-
return pathsToIgnore.has(path) || globsToIgnore.some(glob => glob && isMatch(path, glob));
11-
}
14+
return (
15+
pathsToIgnore.has(path) ||
16+
globsToIgnore.some(
17+
(glob) =>
18+
glob &&
19+
isMatch(processPath(path), glob, {
20+
dot: true,
21+
})
22+
)
23+
);
24+
};
25+
26+
const processPath = (path: string): string => {
27+
if (path.startsWith("./")) return path.substring(2);
28+
return path;
29+
};

0 commit comments

Comments
 (0)