( partialPath: string, basePath?: string, )
| 53 | * Parses a partial path into directory and prefix components |
| 54 | */ |
| 55 | export function parsePartialPath( |
| 56 | partialPath: string, |
| 57 | basePath?: string, |
| 58 | ): ParsedPath { |
| 59 | // Handle empty input |
| 60 | if (!partialPath) { |
| 61 | const directory = basePath || getCwd() |
| 62 | return { directory, prefix: '' } |
| 63 | } |
| 64 | |
| 65 | const resolved = expandPath(partialPath, basePath) |
| 66 | |
| 67 | // If path ends with separator, treat as directory with no prefix |
| 68 | // Handle both forward slash and platform-specific separator |
| 69 | if (partialPath.endsWith('/') || partialPath.endsWith(sep)) { |
| 70 | return { directory: resolved, prefix: '' } |
| 71 | } |
| 72 | |
| 73 | // Split into directory and prefix |
| 74 | const directory = dirname(resolved) |
| 75 | const prefix = basename(partialPath) |
| 76 | |
| 77 | return { directory, prefix } |
| 78 | } |
| 79 | |
| 80 | /** |
| 81 | * Scans a directory and returns subdirectories |
no test coverage detected