blob: 627f1833cb9bcdd59bff0ce088d33d93aed7ed7b [file] [log] [blame]
const colors = require('colors') // eslint-disable-line
const msgPath = process.env.GIT_PARAMS
const msg = require('fs').readFileSync(msgPath, 'utf-8').trim()
const commitRE = /^(v\d+\.\d+\.\d+(-(alpha|beta|rc).\d+)?$)|((revert: )?(feat|bugfix|docs|style|refactor|perf|test|workflow|ci|chore|types)(\(.+\))?: .{1,50})/
if (!commitRE.test(msg)) {
console.error(
`\n ${colors.bgRed.white(' ERROR ')} ${colors.red(`invalid commit message format.`)}\n\n` +
colors.red(` Proper commit message format is required for automated changelog generation. Examples:\n\n`) +
` ${colors.green(`feat(compile): commit message`)}\n` +
` ${colors.green(`fix(module): commit message (close #28)`)}\n\n` +
colors.red(` See .github/COMMIT_CONVENTION.md for more details.\n`)
)
process.exit(1)
}