-
-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathverify_commit.js
49 lines (48 loc) · 1.03 KB
/
verify_commit.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
const fs = require("fs"),
commitMessage = fs.readFileSync(process.env.GIT_PARAMS, "utf-8"),
validCommitRegex = /(feat|fix|remove|refactor|chore|release)\((.+)\)(: )(.{1,50})/;
if (validCommitRegex.test(commitMessage)) {
console.log(
"\x1b[2m" +
"[" +
"\x1b[0m" +
"\x1b[32m" +
"nest.land" +
"\x1b[0m" +
"\x1b[2m" +
"]" +
"\x1b[0m",
"\x1b[32m" + "Valid commit message" + "\x1b[0m"
);
} else {
console.log(
"\x1b[2m" +
"[" +
"\x1b[0m" +
"\x1b[32m" +
"nest.land" +
"\x1b[0m" +
"\x1b[2m" +
"]" +
"\x1b[0m",
"\x1b[31m" +
"Invalid commit message. You can commit like this:\n" +
"\x1b[0m" +
"\x1b[2m" +
"feat(airplane): Add option to fly" +
"\x1b[0m"
);
console.log(
"\x1b[2m" +
"[" +
"\x1b[0m" +
"\x1b[32m" +
"nest.land" +
"\x1b[0m" +
"\x1b[2m" +
"]" +
"\x1b[0m",
"See all of the allowed formats in .github/commits-style.md"
);
process.exit(1);
}