| 71 | } |
| 72 | |
| 73 | function normalizePath(p: string): string { |
| 74 | // normalize resolve ./.. segments, removes duplicate slashes, and standardizes path separators |
| 75 | let normalized = path.normalize(p) |
| 76 | // however it doesn't remove trailing slashes |
| 77 | // remove trailing slash, except for root paths |
| 78 | if (normalized.length > 1 && (normalized.endsWith("/") || normalized.endsWith("\\"))) { |
| 79 | normalized = normalized.slice(0, -1) |
| 80 | } |
| 81 | return normalized |
| 82 | } |
| 83 | |
| 84 | export function getReadablePath(cwd: string, relPath?: string): string { |
| 85 | // If relPath is undefined, return empty string instead of allowing path.resolve |