|
3 | 3 | // hook that validates that a 'BREAKING CHANGE' commit message contains an exclamation mark (!) in |
4 | 4 | // its subject (just after the commit type(scope)) |
5 | 5 |
|
6 | | -// const fs = require('fs'); |
| 6 | +const fs = require('fs'); |
7 | 7 |
|
8 | | -// const message = fs.readFileSync(process.argv[2], 'utf8').trim(); |
| 8 | +const message = fs.readFileSync(process.argv[2], 'utf8').trim(); |
9 | 9 |
|
10 | | -// if (!message.includes('BREAKING CHANGE') || message.includes('chore(release)')) { |
11 | | -// process.exit(0); |
12 | | -// } |
| 10 | +if (!message.includes('BREAKING CHANGE') || message.includes('chore(release)')) { |
| 11 | + process.exit(0); |
| 12 | +} |
13 | 13 |
|
14 | | -// const commitMsgSplitted = message.split('\n'); |
15 | | -// const commitSubject = commitMsgSplitted[0]; |
| 14 | +const commitMsgSplitted = message.split('\n'); |
| 15 | +const commitSubject = commitMsgSplitted[0]; |
16 | 16 |
|
17 | | -// // use the following when MGW-540 is done |
18 | | -// // const commitEmojiAndTypeRegex = /^:[A-Za-z]*: [A-Za-z()]*!:/g; |
19 | | -// // const commitEmojiAndType = commitSubject.match(commitEmojiAndTypeRegex); |
| 17 | +// use the following when MGW-540 is done |
| 18 | +// const commitEmojiAndTypeRegex = /^:[A-Za-z]*: [A-Za-z()]*!:/g; |
| 19 | +// const commitEmojiAndType = commitSubject.match(commitEmojiAndTypeRegex); |
20 | 20 |
|
21 | | -// const commitTypeRegex = /^[A-Za-z()]*!:/g; |
22 | | -// const commitType = commitSubject.match(commitTypeRegex); |
| 21 | +const commitTypeRegex = /^[A-Za-z()]*!:/g; |
| 22 | +const commitType = commitSubject.match(commitTypeRegex); |
23 | 23 |
|
24 | | -// // if (!commitEmojiAndType || commitEmojiAndType.length === 0) { use the following when MGW-540 is done |
25 | | -// if (!commitType || commitType.length === 0) { |
26 | | -// console.log( |
27 | | -// "❌ Wrong commit format for a BREAKING CHANGE. Please add an exclamation mark '!' just after your commit type(scope).\nFor example: :sparkles: feat(ui)!: new component" |
28 | | -// ); |
| 24 | +// if (!commitEmojiAndType || commitEmojiAndType.length === 0) { use the following when MGW-540 is done |
| 25 | +if (!commitType || commitType.length === 0) { |
| 26 | + console.log( |
| 27 | + "❌ Wrong commit format for a BREAKING CHANGE. Please add an exclamation mark '!' just after your commit type(scope).\nFor example: :sparkles: feat(ui)!: new component" |
| 28 | + ); |
29 | 29 |
|
30 | | -// process.exit(1); |
31 | | -// } |
| 30 | + process.exit(1); |
| 31 | +} |
32 | 32 |
|
33 | | -// process.exit(0); |
| 33 | +process.exit(0); |
0 commit comments