husky install for version increment
This commit is contained in:
24
incrementVersion.ts
Normal file
24
incrementVersion.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
// /incrementVersion.ts
|
||||
import fs from "fs";
|
||||
import path from "path";
|
||||
|
||||
const filePath = path.join(__dirname, "../config/webVersion.ts");
|
||||
const fileContent = fs.readFileSync(filePath, "utf8");
|
||||
|
||||
const versionRegex = /const webVersion = "(\d+)\.(\d+)\.(\d+)\.(\d+)";/;
|
||||
const match = fileContent.match(versionRegex);
|
||||
|
||||
if (!match) {
|
||||
console.error("Version format not found!");
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const [_, major, minor, build, patch] = match;
|
||||
const newVersion = `${major}.${minor}.${build}.${parseInt(patch, 10) + 1}`;
|
||||
const updatedContent = fileContent.replace(
|
||||
versionRegex,
|
||||
`const webVersion = "${newVersion}";`
|
||||
);
|
||||
|
||||
fs.writeFileSync(filePath, updatedContent, "utf8");
|
||||
console.log(`Version updated to ${newVersion}`);
|
||||
Reference in New Issue
Block a user