(absolutePath: string)
| 93 | * @returns Relative path if under cwd, otherwise the original absolute path |
| 94 | */ |
| 95 | export function toRelativePath(absolutePath: string): string { |
| 96 | const relativePath = relative(getCwd(), absolutePath) |
| 97 | // If the relative path would go outside cwd (starts with ..), keep absolute |
| 98 | return relativePath.startsWith('..') ? absolutePath : relativePath |
| 99 | } |
| 100 | |
| 101 | /** |
| 102 | * Gets the directory path for a given file or directory path. |