()
| 13 | * @returns true if the directory is in a git repository with a github.com remote, false otherwise |
| 14 | */ |
| 15 | export const isGitHubRepository = (): boolean => { |
| 16 | try { |
| 17 | const remotes = ( |
| 18 | execSync('git remote -v', { |
| 19 | encoding: 'utf-8', |
| 20 | }) || '' |
| 21 | ).trim(); |
| 22 | |
| 23 | const pattern = /github\.com/; |
| 24 | |
| 25 | return pattern.test(remotes); |
| 26 | } catch (_error) { |
| 27 | // If any filesystem error occurs, assume not a git repo |
| 28 | console.debug(`Failed to get git remote:`, _error); |
| 29 | return false; |
| 30 | } |
| 31 | }; |
| 32 | |
| 33 | /** |
| 34 | * getGitRepoRoot returns the root directory of the git repository. |
no test coverage detected