Skip to content

Commit

Permalink
fix(scripts): checkcommit allows release commit (#740)
Browse files Browse the repository at this point in the history
  • Loading branch information
bcabanes authored and FrozenPandaz committed Sep 14, 2018
1 parent c9e29a2 commit 5c4db34
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
19 changes: 8 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,17 @@
"commit": "git-cz",
"checkcommit": "./scripts/commit-lint.js",
"e2e": "./scripts/e2e.sh",
"format": "prettier \"./**/*.{ts,js,json,css,md}\" \"!./**/{__name__,__directory__}/**\" --write",
"format":
"prettier \"./**/*.{ts,js,json,css,md}\" \"!./**/{__name__,__directory__}/**\" --write",
"linknpm": "./scripts/link.sh",
"nx-release": "./scripts/nx-release.js",
"copy": "./scripts/copy.sh",
"test:schematics": "yarn linknpm fast && ./scripts/test_schematics.sh",
"test:nx": "yarn linknpm fast && ./scripts/test_nx.sh",
"test": "yarn linknpm fast && ./scripts/test_nx.sh && ./scripts/test_schematics.sh",
"checkformat": "prettier \"./**/*.{ts,js,json,css,md}\" \"!./**/{__name__,__directory__}/**\" --list-different"
"test":
"yarn linknpm fast && ./scripts/test_nx.sh && ./scripts/test_schematics.sh",
"checkformat":
"prettier \"./**/*.{ts,js,json,css,md}\" \"!./**/{__name__,__directory__}/**\" --list-different"
},
"devDependencies": {
"@angular-devkit/build-angular": "^0.7.2",
Expand Down Expand Up @@ -81,21 +84,15 @@
"author": "Victor Savkin",
"license": "MIT",
"jest": {
"modulePathIgnorePatterns": [
"tmp",
"collection/.*/files"
]
"modulePathIgnorePatterns": ["tmp", "collection/.*/files"]
},
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
},
"lint-staged": {
"./**/*.{ts,js,json,css,md}": [
"prettier --write",
"git add"
]
"./**/*.{ts,js,json,css,md}": ["prettier --write", "git add"]
},
"config": {
"commitizen": {
Expand Down
11 changes: 7 additions & 4 deletions scripts/commit-lint.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,25 @@ const gitMessage = require('child_process')
.execSync('git log -1 --no-merges')
.toString()
.trim();
const matchTest = /([a-z]){0,8}\([a-z.0-9\-]+\):\s(([a-z0-9:\-\s])+)/g.test(
const matchCommit = /([a-z]){0,8}\([a-z.0-9\-]+\):\s(([a-z0-9:\-\s])+)/g.test(
gitMessage
);
const exitCode = +!matchTest;
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 +
'\ndoes not follow the commit message convention specified in the CONTRIBUTING.MD file.'
'\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(
'\nExample: \n ' +
'\nEXAMPLE: \n ' +
'feat(schematics): add an option to generate lazy-loadable modules\n' +
'\n`ng generate lib mylib --lazy` provisions the mylib project in tslint.json'
);
Expand Down

0 comments on commit 5c4db34

Please sign in to comment.