| 27 | * data", so a narrowing that missed a file can never pass silently. |
| 28 | */ |
| 29 | export const narrowToNamedTestFiles = (rootFiles: string[]): string[] => { |
| 30 | if (!getConfig().onlyNamedTestFiles) return rootFiles |
| 31 | const named = new Set( |
| 32 | process.argv |
| 33 | .slice(2) |
| 34 | .filter(arg => testFilePattern.test(arg) && existsSync(arg)) |
| 35 | .map(arg => resolve(arg).replace(/\\/g, "/")) |
| 36 | ) |
| 37 | if (!named.size) return rootFiles |
| 38 | const narrowed = rootFiles.filter(path => named.has(path)) |
| 39 | return narrowed.length ? narrowed : rootFiles |
| 40 | } |
| 41 | |
| 42 | /** |
| 43 | * Can be used to allow arbitrarily chained property access and function calls. |