/* * @Author: Rindy * @Date: 2021-04-29 09:57:47 * @LastEditors: Rindy * @LastEditTime: 2021-04-29 10:10:32 * @Description: git 提交规程检测 */ const chalk = require('chalk') const msgPath = process.env.GIT_PARAMS const msg = require('fs').readFileSync(msgPath, 'utf-8').trim() const commitRE = /^(revert: |Merge )?(feat|fix|docs|dx|style|refactor|perf|test|workflow|build|ci|chore|types|wip|release)(\(.+\))?: .{1,50}/i if (!commitRE.test(msg)) { console.log() console.error( ` ${chalk.bgRed.white(' ERROR ')} ${chalk.red(`Git 提交信息格式错误(注意冒号后的空格)。`)}\n\n` + chalk.red(` Proper commit message format is required for automated changelog generation. Examples:\n\n`) + ` ${chalk.green(`feat(plugin): add 'test' function`)}\n` + ` ${chalk.green(`fix(event): handle events on blur`)}\n\n` + chalk.red(` See commit-convention.md for more details.\n`) ) process.exit(1) }