(filePath: string)
| 27 | * If already relative or project root unavailable, returns the path as-is |
| 28 | */ |
| 29 | export function getRelativePath(filePath: string): string { |
| 30 | // If it's already a relative path, return as-is |
| 31 | if (!filePath.startsWith('/')) return filePath |
| 32 | |
| 33 | const projectRoot = getProjectRoot() |
| 34 | if (!projectRoot) return filePath |
| 35 | |
| 36 | // Use Node's path.relative for proper relative path calculation |
| 37 | return path.relative(projectRoot, filePath) |
| 38 | } |
no test coverage detected