Skip to content

Commit

Permalink
fix(cli): prompt instead of hard errors on dirty repo
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed Dec 9, 2023
1 parent 7071af7 commit de2ae2f
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/cli/run.ts
Expand Up @@ -30,11 +30,19 @@ export async function run(options: RuleOptions = {}) {

if (fs.existsSync(pathFlatConfig)) {
console.log(c.yellow(`${WARN} eslint.config.js already exists, migration wizard exited.`))
return
return process.exit(1)
}

if (!SKIP_GIT_CHECK && !isGitClean())
throw new Error('There are uncommitted changes in the current repository, please commit them and try again')
if (!SKIP_GIT_CHECK && !isGitClean()) {
const { confirmed } = await prompts({
initial: false,
message: 'There are uncommitted changes in the current repository, are you sure to continue?',
name: 'confirmed',
type: 'confirm',
})
if (!confirmed)
return process.exit(1)
}

// Update package.json
console.log(c.cyan(`${ARROW} bumping @antfu/eslint-config to v${version}`))
Expand Down

0 comments on commit de2ae2f

Please sign in to comment.