forked from Wynntils/Wynntils-Legacy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.pre-commit.js
24 lines (21 loc) · 838 Bytes
/
.pre-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
const fs = require("fs");
exports.preCommit = (props) => {
const replace = (path, searchValue, replaceValue) => {
let content = fs.readFileSync(path, "utf-8");
if (content.match(searchValue)) {
fs.writeFileSync(path, content.replace(searchValue, replaceValue));
console.log(`"${path}" changed`);
}
};
const [major, minor, patch, build] = props.version.split(".");
let revision, identifier;
if (props.version.includes("-")) { // e.g. v1.12.1-beta.6
[revision, identifier] = patch.split("-");
} else { // e.g. v1.12.1
revision = patch;
identifier = "";
}
replace("./build.gradle", /(?<=major: )\d+/g, major);
replace("./build.gradle", /(?<=minor: )\d+/g, minor);
replace("./build.gradle", /(?<=revision: )\d+/g, revision);
};