UNPKG

alinea

Version:
28 lines (26 loc) 792 B
import { PLazy } from "../../chunks/chunk-IKINPSS5.js"; import "../../chunks/chunk-NZLE2WMY.js"; // src/backend/util/ExecGit.ts import { localUser } from "alinea/core/User"; import { exec } from "node:child_process"; import { promisify } from "node:util"; var execAsync = promisify(exec); async function execGit(cwd, args) { const { stdout } = await execAsync(`git ${args.join(" ")}`, { cwd }); return stdout.trim(); } function gitUser(cwd) { return PLazy.from(async () => { const [name = localUser.name, email] = (await Promise.all([ execGit(cwd, ["config", "--get", "user.name"]), execGit(cwd, ["config", "--get", "user.email"]) ]).catch(() => [])).map((res) => res ?? void 0); return { ...localUser, name, email }; }); } export { execGit, gitUser };