nx/scripts/commit-lint.js
victor savkin 87f4d45311 Revert "chore(nx): add typescript eslint to 2.1.0"
This reverts commit 12f62ece58c3132f04e331f7f49f39377b3afe43.
2019-09-09 12:21:05 -04:00

36 lines
1.2 KiB
JavaScript
Executable File

#!/usr/bin/env node
console.log('🐟🐟🐟 Validating git commit message 🐟🐟🐟');
const gitMessage = require('child_process')
.execSync('git log -1 --no-merges')
.toString()
.trim();
const matchCommit = /(build|feat|fix|refactor|style|docs)\((backend|testing|web|react|angular|nx)\):\s(([a-z0-9:\-\s])+)/g.test(
gitMessage
);
const matchRelease = /release/gi.test(gitMessage);
const exitCode = +!(matchRelease || matchCommit);
if (exitCode === 0) {
console.log('Commit ACCEPTED 👌');
} else {
console.log(
'[Error]: Ho no! 😦 Your commit message: \n' +
'-------------------------------------------------------------------\n' +
gitMessage +
'\n-------------------------------------------------------------------' +
'\n\n 👉️ Does not follow the commit message convention specified in the CONTRIBUTING.MD file.'
);
console.log('\ntype(scope): subject \n BLANK LINE \n body');
console.log('\n');
console.log('possible types: build|feat|fix|refactor|style|docs');
console.log(
'possible scopes: backend|testing|web|react|angular|nx (if unsure use "nx")'
);
console.log(
'\nEXAMPLE: \n' +
'feat(nx): add an option to generate lazy-loadable modules\n'
);
}
process.exit(exitCode);