Files
quartiles/scripts/install-hooks.mjs
2026-10-26 10:06:30 -04:00

16 lines
588 B
JavaScript

// Points git at the repo's .githooks directory. Runs on `npm install`
// (the "prepare" script). Never fails, so installs work without git
// (e.g. CI / Nixpacks builds).
import { execSync } from 'node:child_process';
import fs from 'node:fs';
try {
if (!fs.existsSync('.git')) process.exit(0);
execSync('git config core.hooksPath .githooks', { stdio: 'ignore' });
// Make sure the hook is executable on macOS/Linux
try { fs.chmodSync('.githooks/pre-commit', 0o755); } catch {}
console.log('Git hooks installed (.githooks)');
} catch {
// git not available: skip silently
}