surshar / claude-code
Claude Code is an agentic coding tool that lives in your terminal, understands your codebase, and helps you code faster by executing routine tasks, explaining complex code, and handling git workflows - all through natural language commands.
Built by Anthropic · github.com/anthropics
| 1 | import type { FsEntry } from 'claude-code' |
| 2 | |
| 3 | import { distinct } from './distinct' |
| 4 | import { VCS_MARKERS } from './vcs-markers' |
| 5 | |
| 6 | /** |
| 7 | * The row's `vcs`: the version-control systems whose marker is in the |
| 8 | * session's directory, Perforce too when P4PORT is set, comma-joined. |
| 9 | * |
| 10 | * @param list lists a directory |
| 11 | * @param cwd the session's directory |
| 12 | * @param hasP4Port whether P4PORT is set |
| 13 | * @returns the systems found, or undefined for none or an unlistable directory |
| 14 | */ |
| 15 | export async function vcsOf( |
| 16 | list: (path: string) => Promise<readonly FsEntry[]>, |
| 17 | cwd: string, |
| 18 | hasP4Port: boolean, |
| 19 | ): Promise<string | undefined> { |
| 20 | let entries: readonly FsEntry[] |
| 21 | |
| 22 | try { |
| 23 | entries = await list(cwd) |
| 24 | } catch { |
| 25 | entries = [] |
| 26 | } |
| 27 | |
| 28 | const names = new Set(entries.map(entry => entry.name)) |
| 29 | |
| 30 | const found = distinct([ |
| 31 | ...(hasP4Port ? ['perforce'] : []), |
| 32 | ...VCS_MARKERS.flatMap(([marker, system]) => |
| 33 | names.has(marker) ? [system] : [], |
| 34 | ), |
| 35 | ]) |
| 36 | |
| 37 | return found.length > 0 ? found.join(',') : undefined |
| 38 | } |