π File detail
utils/getWorktreePathsPortable.ts
π§© .tsπ 28 linesπΎ 847 bytesπ text
β Back to All Filesπ― Use case
This file lives under βutils/β, which covers cross-cutting helpers (shell, tempfiles, settings, messages, process input, β¦). On the API surface it exposes getWorktreePathsPortable β mainly functions, hooks, or classes. Dependencies touch subprocess spawning and Node util helpers.
Generated from folder role, exports, dependency roots, and inline comments β not hand-reviewed for every path.
π§ Inline summary
import { execFile as execFileCb } from 'child_process' import { promisify } from 'util' const execFileAsync = promisify(execFileCb)
π€ Exports (heuristic)
getWorktreePathsPortable
π External import roots
Package roots from from "β¦" (relative paths omitted).
child_processutil
π₯οΈ Source preview
import { execFile as execFileCb } from 'child_process'
import { promisify } from 'util'
const execFileAsync = promisify(execFileCb)
/**
* Portable worktree detection using only child_process β no analytics,
* no bootstrap deps, no execa. Used by listSessionsImpl.ts (SDK) and
* anywhere that needs worktree paths without pulling in the CLI
* dependency chain (execa β cross-spawn β which).
*/
export async function getWorktreePathsPortable(cwd: string): Promise<string[]> {
try {
const { stdout } = await execFileAsync(
'git',
['worktree', 'list', '--porcelain'],
{ cwd, timeout: 5000 },
)
if (!stdout) return []
return stdout
.split('\n')
.filter(line => line.startsWith('worktree '))
.map(line => line.slice('worktree '.length).normalize('NFC'))
} catch {
return []
}
}