(projectRoot: string)
| 39 | * isn't installed or the path isn't a repo. |
| 40 | */ |
| 41 | export function isGitRepo(projectRoot: string): boolean { |
| 42 | try { |
| 43 | const out = execFileSync('git', ['rev-parse', '--is-inside-work-tree'], { |
| 44 | cwd: projectRoot, |
| 45 | encoding: 'utf8', |
| 46 | stdio: ['ignore', 'pipe', 'ignore'], |
| 47 | windowsHide: true, |
| 48 | timeout: 5000, // fail fast instead of hanging init/sync on a stuck git (#1139) |
| 49 | }).trim(); |
| 50 | return out === 'true'; |
| 51 | } catch { |
| 52 | return false; |
| 53 | } |
| 54 | } |
| 55 | |
| 56 | /** |
| 57 | * Resolve the git hooks directory for a project, honoring `core.hooksPath` |
no outgoing calls
no test coverage detected