mirror of
https://github.com/jarrodwatts/claude-hud.git
synced 2026-05-06 12:32:39 +00:00
15 lines
468 B
JavaScript
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
|