Skip to content

Commit c5870d3

Browse files
authored
Create check-commit-mail.js
1 parent fb7af08 commit c5870d3

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

scripts/check-commit-mail.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/usr/bin/env node
2+
import * as ChildProcess from 'node:child_process';
3+
import * as process from 'node:process';
4+
import * as dotenv from 'dotenv';
5+
6+
dotenv.config();
7+
8+
const checkCommitMail = () => {
9+
console.warn(`Check COMMIT_MAIL`);
10+
if (!process.env.COMMIT_MAIL) {
11+
console.error(
12+
`No COMMIT_MAIL set in .env, please take a look at the file '.env.template'`
13+
);
14+
process.exit(1);
15+
}
16+
17+
const currentMail = ChildProcess.execSync('git config user.email')
18+
.toString()
19+
.trim()
20+
.toLowerCase();
21+
const commitMail = process.env.COMMIT_MAIL.trim().toLowerCase();
22+
if (currentMail !== commitMail) {
23+
console.error(
24+
`currentMail: ${currentMail} !== initialMail: ${commitMail}`
25+
);
26+
console.error(
27+
`Please set your commit user mail for this project like: 'git config user.email '${commitMail}''`
28+
);
29+
process.exit(1);
30+
}
31+
};
32+
33+
checkCommitMail();

0 commit comments

Comments
 (0)