Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prompt-cli: check stage before entering prompt #51

Closed
marionebl opened this issue Jul 23, 2017 · 2 comments
Closed

prompt-cli: check stage before entering prompt #51

marionebl opened this issue Jul 23, 2017 · 2 comments

Comments

@marionebl
Copy link
Contributor

marionebl commented Jul 23, 2017

@commitlint/prompt-cli fails for empty git stages after authoring the commit message. This makes for a frustrating experience.

Check if there are files in stage before entering the prompt.


Edit

The implementation for this should happen before this line: @commitlint/prompt-cli/cli.js#L21

main could look like this:

async function main() {
  if (await isStageEmpty())  {
    console.log(`Nothing to commit. Stage your changes via "git add" execute "commit" again`);
    process.exit(1);
  }

  return prompt();
}

async function isStageEmpty() {
   const result = await execa('git', ['diff', '--cached']);
   return result.stdout === '';
}
@lostintangent
Copy link

I've run into this issue a couple times now, and would love to see the CLI fail early here.

escapedcat added a commit to escapedcat/commitlint that referenced this issue Oct 5, 2018
escapedcat added a commit to escapedcat/commitlint that referenced this issue Nov 8, 2018
marionebl added a commit that referenced this issue Nov 25, 2018
* feat(prompt-cli): check stage before prompt #51

* feat(prompt-cli): add test #51

* chore: linting

* fix: add missing dev dependencies

* chore: ensure Node.js 6 compat
@marionebl
Copy link
Contributor Author

Landed in master via #495

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants