(cwd: string)
| 61 | } |
| 62 | |
| 63 | function resolveProjectIDsForCwd(cwd: string): string[] { |
| 64 | const normalizedCwd = path.resolve(cwd) |
| 65 | let files: string[] |
| 66 | try { |
| 67 | files = fs.readdirSync(PROJECT_ROOT) |
| 68 | } catch { |
| 69 | return [] |
| 70 | } |
| 71 | |
| 72 | const matches: string[] = [] |
| 73 | for (const file of files) { |
| 74 | if (!file.endsWith(".json")) continue |
| 75 | const project = readJson<StoredProjectRecord>(path.join(PROJECT_ROOT, file)) |
| 76 | if (!project?.worktree) continue |
| 77 | const normalizedWorktree = path.resolve(project.worktree) |
| 78 | if (pathsOverlap(normalizedWorktree, normalizedCwd)) { |
| 79 | matches.push(project.id ?? file.replace(/\.json$/, "")) |
| 80 | } |
| 81 | } |
| 82 | return matches |
| 83 | } |
| 84 | |
| 85 | function listAllProjectIDs(): string[] { |
| 86 | try { |
no test coverage detected