* Finds the folder that contains the .git folder * * For example, if the .git folder is /Users/sparky/projects/my-web-app/.git * This function will return /Users/sparky/projects/my-web-app * * Modeled after https://github.com/firebase/firebase-tools/blob/main/src/detectProjectRoot.ts * * @ret
()
| 224 | * @return {string} The folder that contains the .git folder |
| 225 | */ |
| 226 | function getGitFolderPath(): string { |
| 227 | const commandDir = process.cwd(); |
| 228 | let projectRootDir = commandDir; |
| 229 | |
| 230 | while (!fs.existsSync(path.resolve(projectRootDir, ".git"))) { |
| 231 | const parentDir = path.dirname(projectRootDir); |
| 232 | |
| 233 | // Stop searching if we get to the root of the filesystem |
| 234 | if (parentDir === projectRootDir) { |
| 235 | logBullet(`Didn't detect a .git folder. Assuming ${commandDir} is the project root.`); |
| 236 | return commandDir; |
| 237 | } |
| 238 | projectRootDir = parentDir; |
| 239 | } |
| 240 | |
| 241 | logBullet(`Detected a .git folder at ${projectRootDir}`); |
| 242 | return projectRootDir; |
| 243 | } |
| 244 | |
| 245 | function defaultGithubRepo(): string | undefined { |
| 246 | const gitConfigPath = path.join(GIT_DIR, "config"); |
no test coverage detected
searching dependent graphs…