verifyCommit.js 834 B

123456789101112131415161718192021222324
  1. // Invoked on the commit-msg git hook by yorkie.
  2. import chalk from 'chalk'
  3. import minimist from 'minimist'
  4. const msg = minimist(process.argv.slice(2)).msg
  5. const commitRE =
  6. /^(revert: )?(feat|fix|docs|dx|style|refactor|perf|test|workflow|build|ci|chore|types|wip|release): .{1,50}/
  7. if (!commitRE.test(msg)) {
  8. console.error(
  9. ` ${chalk.bgRed.white(' ERROR ')} ${chalk.red(
  10. 'invalid commit message format.'
  11. )}\n\n` +
  12. chalk.red(
  13. ' Proper commit message format is required for automated changelog generation. Examples:\n\n'
  14. ) +
  15. ` ${chalk.green("feat(compiler): add 'comments' option")}\n` +
  16. ` ${chalk.green(
  17. 'fix(v-model): handle events on blur (close #28)'
  18. )}\n\n` +
  19. chalk.red(' See .github/commit-convention.md for more details.\n')
  20. )
  21. process.exit(1)
  22. }