IOweb/node_modules/@iconify/tools/lib/download/git/branch.mjs
2026-07-03 15:07:38 -05:00

17 lines
503 B
JavaScript

import { execAsync } from '../../misc/exec.mjs';
import 'pathe';
import 'child_process';
async function getGitRepoBranch(options, checkout) {
const result = await execAsync("git branch --show-current", {
cwd: options.target
});
const branch = result.stdout.trim();
if (typeof checkout === "string" && branch !== checkout) {
await execAsync(`git checkout ${checkout} "${options.target}"`);
return await getGitRepoBranch(options);
}
return branch;
}
export { getGitRepoBranch };