Files
claude-hud/dist/git.js
2026-01-05 04:06:24 +00:00

15 lines
468 B
JavaScript

import { execFile } from 'node:child_process';
import { promisify } from 'node:util';
const execFileAsync = promisify(execFile);
export async function getGitBranch(cwd) {
if (!cwd)
return null;
try {
const { stdout } = await execFileAsync('git', ['rev-parse', '--abbrev-ref', 'HEAD'], { cwd, timeout: 1000, encoding: 'utf8' });
return stdout.trim() || null;
}
catch {
return null;
}
}
//# sourceMappingURL=git.js.map