(target: string)
| 1 | import * as isGlob from 'is-glob' |
| 2 | |
| 3 | export function parseGlob(target: string): { |
| 4 | base: string |
| 5 | glob: string |
| 6 | is: { |
| 7 | glob: boolean |
| 8 | } |
| 9 | path: { |
| 10 | basename: string |
| 11 | } |
| 12 | } { |
| 13 | const recursiveTokenIndex = Math.max( |
| 14 | target.indexOf('**/'), |
| 15 | target.indexOf('**\\') |
| 16 | ) |
| 17 | const lastSlashIndex = Math.max( |
| 18 | target.lastIndexOf('/'), |
| 19 | target.lastIndexOf('\\') |
| 20 | ) |
| 21 | const baseGlobSepIndex = |
| 22 | recursiveTokenIndex >= 0 ? recursiveTokenIndex : Math.max(lastSlashIndex, 0) |
| 23 | |
| 24 | return { |
| 25 | base: target.substring(0, baseGlobSepIndex).replace(/[/\\]$/, '') || '.', |
| 26 | glob: target.substring(baseGlobSepIndex).replace(/^[/\\]/, ''), |
| 27 | is: { |
| 28 | glob: isGlob(target), |
| 29 | }, |
| 30 | path: { |
| 31 | basename: target |
| 32 | .substring(Math.max(lastSlashIndex, 0)) |
| 33 | .replace(/^[/\\]/, ''), |
| 34 | }, |
| 35 | } |
| 36 | } |
no outgoing calls
no test coverage detected