({
path,
onProgress,
signal,
}: {
path: string,
onProgress?: onProgressFn,
signal?: AbortSignal
})
| 247 | * Returns true if `path` is the _root_ of a git repository. |
| 248 | */ |
| 249 | export const isPathAValidGitRepoRoot = async ({ |
| 250 | path, |
| 251 | onProgress, |
| 252 | signal, |
| 253 | }: { |
| 254 | path: string, |
| 255 | onProgress?: onProgressFn, |
| 256 | signal?: AbortSignal |
| 257 | }) => { |
| 258 | if (!existsSync(path)) { |
| 259 | return false; |
| 260 | } |
| 261 | |
| 262 | const git = createGitClientForPath(path, onProgress, signal); |
| 263 | |
| 264 | try { |
| 265 | return git.checkIsRepo(CheckRepoActions.IS_REPO_ROOT); |
| 266 | } catch (error: unknown) { |
| 267 | if (error instanceof Error) { |
| 268 | throw new Error(`isPathAGitRepoRoot failed: ${error.message}`); |
| 269 | } else { |
| 270 | throw new Error(`isPathAGitRepoRoot failed: ${error}`); |
| 271 | } |
| 272 | } |
| 273 | } |
| 274 | |
| 275 | export const isUrlAValidGitRepo = async (url: string) => { |
| 276 | const git = simpleGit(); |
no test coverage detected