(fullPath: string)
| 103 | |
| 104 | /** Parent directory; supports mixed separators and Unix root (`/` parent of `/foo`). */ |
| 105 | export function dirnameAbsolutePath(fullPath: string): string { |
| 106 | if (!fullPath || typeof fullPath !== 'string') return ''; |
| 107 | const i = Math.max(fullPath.lastIndexOf('/'), fullPath.lastIndexOf('\\')); |
| 108 | if (i < 0) return ''; |
| 109 | if (i === 0) return fullPath[0] === '/' ? '/' : ''; |
| 110 | return fullPath.slice(0, i); |
| 111 | } |
| 112 | |
| 113 | /** Replace the final segment; keeps the separator style before the basename. */ |
| 114 | export function replaceBasename(fullPath: string, newName: string): string { |
no test coverage detected