(dir?: string)
| 129 | ] |
| 130 | |
| 131 | export async function detectVcs(dir?: string): Promise<string[]> { |
| 132 | const detected = new Set<string>() |
| 133 | |
| 134 | // Check for Perforce via env var |
| 135 | if (process.env.P4PORT) { |
| 136 | detected.add('perforce') |
| 137 | } |
| 138 | |
| 139 | try { |
| 140 | const targetDir = dir ?? getFsImplementation().cwd() |
| 141 | const entries = new Set(await readdir(targetDir)) |
| 142 | for (const [marker, vcs] of VCS_MARKERS) { |
| 143 | if (entries.has(marker)) { |
| 144 | detected.add(vcs) |
| 145 | } |
| 146 | } |
| 147 | } catch { |
| 148 | // Directory may not be readable |
| 149 | } |
| 150 | |
| 151 | return [...detected] |
| 152 | } |
no test coverage detected