(dirPath: string)
| 343 | * @returns An error message if invalid, or null if valid |
| 344 | */ |
| 345 | export function validateProjectPath(dirPath: string): string | null { |
| 346 | const refusal = sensitiveDirectoryRefusal(dirPath); |
| 347 | if (refusal) return refusal; |
| 348 | |
| 349 | // Verify it's a real directory |
| 350 | const resolved = path.resolve(dirPath); |
| 351 | try { |
| 352 | const stats = fs.statSync(resolved); |
| 353 | if (!stats.isDirectory()) { |
| 354 | return `Path is not a directory: ${resolved}`; |
| 355 | } |
| 356 | } catch { |
| 357 | return `Path does not exist or is not accessible: ${resolved}`; |
| 358 | } |
| 359 | |
| 360 | return null; |
| 361 | } |
| 362 | |
| 363 | /** |
| 364 | * The sensitive-folder half of {@link validateProjectPath}: why `dirPath` is, |
no test coverage detected