Skip to content

Commit

Permalink
fix: update micromatch glob matching
Browse files Browse the repository at this point in the history
- match folders that start with .
- remove leading ./ when glob matching
fixes #35
  • Loading branch information
repo-visualizer committed Sep 1, 2021
1 parent 62c798d commit fd43c6c
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 6 deletions.
9 changes: 8 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18498,7 +18498,14 @@ var import_micromatch = __toModule(require_micromatch());
var shouldExcludePath = (path, pathsToIgnore, globsToIgnore) => {
if (!path)
return false;
return pathsToIgnore.has(path) || globsToIgnore.some((glob) => glob && (0, import_micromatch.isMatch)(path, glob));
return pathsToIgnore.has(path) || globsToIgnore.some((glob) => glob && (0, import_micromatch.isMatch)(processPath(path), glob, {
dot: true
}));
};
var processPath = (path) => {
if (path.startsWith("./"))
return path.substring(2);
return path;
};

// src/process-dir.js
Expand Down
28 changes: 23 additions & 5 deletions src/should-exclude-path.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,29 @@
import { isMatch } from 'micromatch';
import { isMatch } from "micromatch";

/**
* True if path is excluded by either the path or glob criteria.
* path may be to a directory or individual file.
*/
export const shouldExcludePath = (path: string, pathsToIgnore: Set<string>, globsToIgnore: string[]): boolean => {
if (!path) return false
export const shouldExcludePath = (
path: string,
pathsToIgnore: Set<string>,
globsToIgnore: string[]
): boolean => {
if (!path) return false;

return pathsToIgnore.has(path) || globsToIgnore.some(glob => glob && isMatch(path, glob));
}
return (
pathsToIgnore.has(path) ||
globsToIgnore.some(
(glob) =>
glob &&
isMatch(processPath(path), glob, {
dot: true,
})
)
);
};

const processPath = (path: string): string => {
if (path.startsWith("./")) return path.substring(2);
return path;
};

0 comments on commit fd43c6c

Please sign in to comment.