(cwd: string | undefined, env?: CliEnv)
| 12 | * @param env - Optional environment object (defaults to CLI env) |
| 13 | */ |
| 14 | export function formatCwd(cwd: string | undefined, env?: CliEnv): string { |
| 15 | if (!cwd) return '' |
| 16 | const resolvedEnv = env ?? getCliEnv() |
| 17 | const homeDir = resolvedEnv.HOME || resolvedEnv.USERPROFILE || os.homedir() |
| 18 | if (homeDir && cwd.startsWith(homeDir)) { |
| 19 | return '~' + cwd.slice(homeDir.length) |
| 20 | } |
| 21 | return cwd |
| 22 | } |
| 23 | |
| 24 | /** |
| 25 | * Get relative path from the project root |
no test coverage detected