* Split an abbreviated path into directory path and basename
(filePath: string)
| 159 | * Split an abbreviated path into directory path and basename |
| 160 | */ |
| 161 | static splitAbbreviated(filePath: string): { dirPath: string; basename: string } { |
| 162 | if (!filePath || typeof filePath !== "string") { |
| 163 | return { dirPath: "", basename: filePath }; |
| 164 | } |
| 165 | |
| 166 | const sep = isWindowsPlatform() ? (filePath.includes("\\") ? "\\" : "/") : "/"; |
| 167 | const lastSlash = filePath.lastIndexOf(sep); |
| 168 | if (lastSlash === -1) { |
| 169 | return { dirPath: "", basename: filePath }; |
| 170 | } |
| 171 | return { |
| 172 | dirPath: filePath.slice(0, lastSlash + 1), |
| 173 | basename: filePath.slice(lastSlash + 1), |
| 174 | }; |
| 175 | } |
| 176 | |
| 177 | /** |
| 178 | * Format home directory path for display (shows ~ on Unix, full path on Windows) |
no test coverage detected