(id: string, resolutionBase: string | false | null | undefined)
| 8 | import normalizePath from './normalizePath'; |
| 9 | |
| 10 | function getMatcherString(id: string, resolutionBase: string | false | null | undefined) { |
| 11 | if (resolutionBase === false || isAbsolute(id) || id.startsWith('**')) { |
| 12 | return normalizePath(id); |
| 13 | } |
| 14 | |
| 15 | // resolve('') is valid and will default to process.cwd() |
| 16 | const basePath = normalizePath(resolve(resolutionBase || '')) |
| 17 | // escape all possible (posix + win) path characters that might interfere with regex |
| 18 | .replace(/[-^$*+?.()|[\]{}]/g, '\\$&'); |
| 19 | // Note that we use posix.join because: |
| 20 | // 1. the basePath has been normalized to use / |
| 21 | // 2. the incoming glob (id) matcher, also uses / |
| 22 | // otherwise Node will force backslash (\) on windows |
| 23 | return posix.join(basePath, normalizePath(id)); |
| 24 | } |
| 25 | |
| 26 | const createFilter: CreateFilter = function createFilter(include?, exclude?, options?) { |
| 27 | const resolutionBase = options && options.resolve; |
no test coverage detected