* Resolve the git hooks directory for a project, honoring `core.hooksPath` * and git worktrees. Returns an absolute path, or null when not a repo.
(projectRoot: string)
| 71 | * and git worktrees. Returns an absolute path, or null when not a repo. |
| 72 | */ |
| 73 | function gitHooksDir(projectRoot: string): string | null { |
| 74 | try { |
| 75 | const out = execFileSync('git', ['rev-parse', '--git-path', 'hooks'], { |
| 76 | cwd: projectRoot, |
| 77 | encoding: 'utf8', |
| 78 | stdio: ['ignore', 'pipe', 'ignore'], |
| 79 | windowsHide: true, |
| 80 | timeout: 5000, // same rationale as isGitRepo |
| 81 | }).trim(); |
| 82 | if (!out) return null; |
| 83 | return path.isAbsolute(out) ? out : path.resolve(projectRoot, out); |
| 84 | } catch { |
| 85 | return null; |
| 86 | } |
| 87 | } |
| 88 | |
| 89 | /** |
| 90 | * The key a block records for its project: the resolved root with forward |
no test coverage detected