(absolutePath: string, baseDir: string)
| 12 | } |
| 13 | |
| 14 | export function toCleanPath(absolutePath: string, baseDir: string): string { |
| 15 | const normalizedPath = absolutePath.replace(/\\/g, '/') |
| 16 | const normalizedBase = baseDir.replace(/\\/g, '/') |
| 17 | let cleanPath = normalizedPath |
| 18 | if (normalizedPath.startsWith(normalizedBase)) { |
| 19 | cleanPath = normalizedPath.slice(normalizedBase.length) |
| 20 | } else if (hasDrive(normalizedPath) !== hasDrive(normalizedBase)) { |
| 21 | const pathNoDrive = stripDrive(normalizedPath) |
| 22 | const baseNoDrive = stripDrive(normalizedBase) |
| 23 | if (pathNoDrive.startsWith(baseNoDrive)) { |
| 24 | cleanPath = pathNoDrive.slice(baseNoDrive.length) |
| 25 | } |
| 26 | } |
| 27 | if (cleanPath.startsWith('/')) { |
| 28 | cleanPath = cleanPath.slice(1) |
| 29 | } |
| 30 | return cleanPath |
| 31 | } |
| 32 | |
| 33 | export function relativePath( |
| 34 | from: string, |
no test coverage detected