husky-commit-lint.js 641 B

123456789101112131415161718192021222324
  1. const chalk = require('chalk')
  2. const spawn = require('child_process').spawn
  3. const args = process.argv.splice(process.execArgv.length + 2);
  4. console.log(chalk.yellow('🐶 Checking the commit message...'))
  5. const child = spawn('commitlint', args, { shell: true })
  6. child.stdout.on('data', function (data) {
  7. process.stdout.write(data)
  8. })
  9. child.on('error', function (err) {
  10. console.log(chalk.red(err))
  11. })
  12. child.on('exit', function (code) {
  13. if(code !== 0){
  14. console.log(chalk.yellow('🐶 ✗ Commit message is invalid.'))
  15. console.log(chalk.yellow(' See https://git.io/contribute for help'))
  16. process.exit(code);
  17. }
  18. })