(force)
| 2 | import isGitClean from 'is-git-clean' |
| 3 | |
| 4 | export function checkGitStatus(force) { |
| 5 | let clean = false |
| 6 | let errorMessage = 'Unable to determine if git directory is clean' |
| 7 | try { |
| 8 | clean = isGitClean.sync(process.cwd()) |
| 9 | errorMessage = 'Git directory is not clean' |
| 10 | } catch (err) { |
| 11 | if (err && err.stderr && err.stderr.includes('Not a git repository')) { |
| 12 | clean = true |
| 13 | } |
| 14 | } |
| 15 | |
| 16 | if (!clean) { |
| 17 | if (force) { |
| 18 | console.log(`WARNING: ${errorMessage}. Forcibly continuing.`) |
| 19 | } else { |
| 20 | console.log('Thank you for using @next/codemod!') |
| 21 | console.log( |
| 22 | yellow( |
| 23 | '\nBut before we continue, please stash or commit your git changes.' |
| 24 | ) |
| 25 | ) |
| 26 | console.log( |
| 27 | '\nYou may use the --force flag to override this safety check.' |
| 28 | ) |
| 29 | process.exit(1) |
| 30 | } |
| 31 | } |
| 32 | } |
| 33 | |
| 34 | export function onCancel() { |
| 35 | process.exit(1) |
no test coverage detected
searching dependent graphs…