2
0

verifyCommit.js 892 B

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