(absolutePath: string)
| 118 | * @returns Relative path if under cwd, otherwise the original absolute path |
| 119 | */ |
| 120 | export function toRelativePath(absolutePath: string): string { |
| 121 | const relativePath = relative(getCwd(), absolutePath) |
| 122 | // If the relative path would go outside cwd (starts with ..), keep absolute |
| 123 | return relativePath.startsWith('..') ? absolutePath : relativePath |
| 124 | } |
| 125 | |
| 126 | /** |
| 127 | * Gets the directory path for a given file or directory path. |
no test coverage detected