()
| 26 | * Falls back to ~/.plannotator when the env var is absent or empty. |
| 27 | */ |
| 28 | export function getPlannotatorDataDir(): string { |
| 29 | const envDir = process.env.PLANNOTATOR_DATA_DIR?.trim(); |
| 30 | if (!envDir) { |
| 31 | return join(homedir(), ".plannotator"); |
| 32 | } |
| 33 | |
| 34 | // Expand ~ to home directory |
| 35 | const home = homedir(); |
| 36 | if (envDir === "~") return home; |
| 37 | if (envDir.startsWith("~/") || envDir.startsWith("~\\")) { |
| 38 | return join(home, envDir.slice(2)); |
| 39 | } |
| 40 | |
| 41 | return resolve(envDir); |
| 42 | } |
no test coverage detected