()
| 21 | * 3. null (if nothing useful found) |
| 22 | */ |
| 23 | export async function detectProjectName(): Promise<string | null> { |
| 24 | // Try git repo name first |
| 25 | try { |
| 26 | const result = await $`git rev-parse --show-toplevel`.quiet().nothrow(); |
| 27 | if (result.exitCode === 0) { |
| 28 | const repoName = extractRepoName(result.stdout.toString()); |
| 29 | if (repoName) return repoName; |
| 30 | } |
| 31 | } catch { |
| 32 | // Git not available or not in a repo - continue to fallback |
| 33 | } |
| 34 | |
| 35 | // Fallback to current directory name |
| 36 | try { |
| 37 | const cwd = process.cwd(); |
| 38 | const dirName = extractDirName(cwd); |
| 39 | if (dirName) return dirName; |
| 40 | } catch { |
| 41 | // process.cwd() failed (rare) |
| 42 | } |
| 43 | |
| 44 | return null; |
| 45 | } |
no test coverage detected