UNPKG

rattail

Version:

A Vite+ oriented, AI Agent friendly front-end toolchain

32 lines (31 loc) 1.12 kB
import { t as __exportAll } from "./rolldown-runtime-Dfn8tqD8.mjs"; import { n as getConfig } from "./config-CpH0B9DB.mjs"; import fs from "node:fs"; import { dirname, resolve } from "node:path"; import { execSync } from "node:child_process"; //#region src/cli/hook.ts var hook_exports = /* @__PURE__ */ __exportAll({ getHooksDir: () => getHooksDir, hook: () => hook, writeHooks: () => writeHooks }); function getHooksDir() { try { const hooksPath = execSync("git config core.hooksPath", { encoding: "utf-8" }).trim(); return resolve(process.cwd(), dirname(hooksPath)); } catch { throw new Error("core.hooksPath is not set. Run \"vp config --hooks-dir <dir>\" first."); } } function writeHooks(hookConfig, hooksDir) { const resolvedDir = hooksDir ?? getHooksDir(); for (const [hookName, commands] of Object.entries(hookConfig)) { const hookFile = resolve(resolvedDir, hookName); fs.writeFileSync(hookFile, commands.join("\n") + "\n"); } } async function hook() { writeHooks((await getConfig()).hook ?? {}); } //#endregion export { writeHooks as i, hook as n, hook_exports as r, getHooksDir as t };