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