(cwd?: string)
| 1 | import { execSync } from 'node:child_process' |
| 2 | |
| 3 | export function isRepoDirty(cwd?: string) { |
| 4 | try { |
| 5 | let stdout = execSync('git status --porcelain', { encoding: 'utf-8', cwd }) |
| 6 | return stdout.trim() !== '' |
| 7 | } catch (error) { |
| 8 | // If it's not a git repository we don't know if it's dirty or not. But we |
| 9 | // also don't want to block the migration. Maybe we can still fail and |
| 10 | // require a `--force` flag? |
| 11 | if (error?.toString?.().includes('not a git repository')) { |
| 12 | return false |
| 13 | } |
| 14 | |
| 15 | return true |
| 16 | } |
| 17 | } |
no outgoing calls
no test coverage detected