Improvements
This commit is contained in:
parent
201f9aeaee
commit
6647a4e632
1 changed files with 104 additions and 60 deletions
|
|
@ -5,8 +5,14 @@ export function toUnixPath(nativePath: string): string {
|
|||
return nativePath.split(path.sep).join(path.posix.sep);
|
||||
}
|
||||
|
||||
// Match a file path against a glob pattern
|
||||
// Extends path.matchesGlob so that "dir/**" also matches the directory itself
|
||||
// Match a file path against a glob pattern.
|
||||
//
|
||||
// Behaves like Node's path.matchesGlob with one extension: `dir/**` matches
|
||||
// the directory `dir` itself, not only its descendants. The watcher feeds us
|
||||
// a directory's relative path (e.g. ".git") at the same time it's about to
|
||||
// recurse into it, and the natural way for users to write the ignore pattern
|
||||
// is `.git/**` — under stdlib semantics that pattern would let the directory
|
||||
// through and only block its children, defeating the prune.
|
||||
export function matchesGlob(filePath: string, pattern: string): boolean {
|
||||
if (pattern.endsWith("/**") && filePath === pattern.slice(0, -3)) {
|
||||
return true;
|
||||
|
|
|
|||
Loading…
Reference in a new issue