29 lines · 800 B · JavaScript
RawDownload
import { execFileSync } from "node:child_process";import { chmodSync, readdirSync } from "node:fs";import path from "node:path";import { fileURLToPath } from "node:url"; const repoRoot = path.dirname(path.dirname(fileURLToPath(import.meta.url)));const hooksDir = path.join(repoRoot, ".githooks"); const runGit = (args) =>  execFileSync("git", args, { cwd: repoRoot, stdio: "ignore" }); const markHooksExecutable = () => {  for (const entry of readdirSync(hooksDir)) {    try {      chmodSync(path.join(hooksDir, entry), 0o755);    } catch {      continue;    }  }}; try {  runGit(["rev-parse", "--git-dir"]);  runGit(["config", "core.hooksPath", ".githooks"]);  markHooksExecutable();} catch (error) {  console.error(`[setup-git-hooks] skipped: ${error}`);  process.exit(0);}

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t