1 | import path from 'path';
|
2 |
|
3 | import minimatch from 'minimatch';
|
4 | import { normalizeFileName } from '@stryker-mutator/util';
|
5 |
|
6 |
|
7 |
|
8 |
|
9 | export class FileMatcher {
|
10 | private readonly pattern: boolean | string;
|
11 |
|
12 | constructor(pattern: boolean | string) {
|
13 | if (typeof pattern === 'string') {
|
14 | this.pattern = normalizeFileName(path.resolve(pattern));
|
15 | } else {
|
16 | this.pattern = pattern;
|
17 | }
|
18 | }
|
19 |
|
20 | public matches(fileName: string): boolean {
|
21 | if (typeof this.pattern === 'string') {
|
22 | return minimatch(normalizeFileName(path.resolve(fileName)), this.pattern);
|
23 | } else {
|
24 | return this.pattern;
|
25 | }
|
26 | }
|
27 | }
|