-
Notifications
You must be signed in to change notification settings - Fork 125
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: update micromatch glob matching
- 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
Showing
2 changed files
with
31 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
}; |