352
353
export function normalizeWatcherPattern(path: string, pattern: string | IRelativePattern): string | IRelativePattern {
355
>
// Patterns are always matched on the full absolute path
356
>
// of the event. As such, if the pattern is not absolute
357
>
// and is a string and does not start with a leading
358
>
// `**`, we have to convert it to a relative pattern with
359
>
// the given `base`
360
>
361
>
if (typeof pattern === 'string' && !pattern.startsWith(GLOBSTAR) && !isAbsolute(pattern)) {
362
>
return { base: path, pattern };
363
>
}
364
>
365
>
return pattern;
366
>
}
367
368
export function parseWatcherPatterns(path: string, patterns: Array<string | IRelativePattern>, ignoreCase: boolean): ParsedPattern[] {
369
>
const parsedPatterns: ParsedPattern[] = [];
watcher.ts
370
>
371
>
for (const pattern of patterns) {
372
>
parsedPatterns.push(parse(normalizeWatcherPattern(path, pattern), { ignoreCase }));
373
>
}
374
>
375
>
return parsedPatterns;
376
>
}
377
378
class EventCoalescer {