* Extract basename from path (OS-aware)
(filePath: string)
| 49 | * Extract basename from path (OS-aware) |
| 50 | */ |
| 51 | static basename(filePath: string): string { |
| 52 | if (!filePath || typeof filePath !== "string") { |
| 53 | return filePath; |
| 54 | } |
| 55 | |
| 56 | const lastSlash = isWindowsPlatform() |
| 57 | ? Math.max(filePath.lastIndexOf("/"), filePath.lastIndexOf("\\")) |
| 58 | : filePath.lastIndexOf("/"); |
| 59 | if (lastSlash === -1) { |
| 60 | return filePath; |
| 61 | } |
| 62 | return filePath.slice(lastSlash + 1); |
| 63 | } |
| 64 | |
| 65 | /** |
| 66 | * Split path into components (OS-aware) |