| 113 | * keeping "what we materialize" identical to "what grep filters in". |
| 114 | */ |
| 115 | export function pathWithinGrepScope(filePath: string, scope: string): boolean { |
| 116 | const scopeUsesStarOrQuestionGlob = /[*?]/.test(scope) |
| 117 | if (scopeUsesStarOrQuestionGlob) { |
| 118 | return micromatch.isMatch(filePath, scope, VFS_GLOB_OPTIONS) |
| 119 | } |
| 120 | const base = scope.replace(/\/+$/, '') |
| 121 | if (base === '') { |
| 122 | return true |
| 123 | } |
| 124 | return filePath === base || filePath.startsWith(`${base}/`) |
| 125 | } |
| 126 | |
| 127 | /** |
| 128 | * Regex search over VFS file contents using ECMAScript `RegExp` syntax. |