Skip to content

Commit

Permalink
dev: fix bump script +1 operator
Browse files Browse the repository at this point in the history
  • Loading branch information
amrbashir committed Dec 10, 2024
1 parent d100983 commit 073afdf
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions .scripts/bump.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ const fs = require("fs");
const bump = process.argv[2];

if (!["major", "minor", "patch"].includes(bump)) {
console.error(`Unkown bump type: ${bump}`);
process.exit(1);
console.error(`Unkown bump type: ${bump}`);
process.exit(1);
}

const appGradle = path.resolve(__dirname, "..", "app", "build.gradle.kts");
Expand All @@ -27,25 +27,25 @@ let minor = Number(mi);
let patch = Number(pa);

switch (bump) {
case "major":
major = +1;
minor = 0;
patch = 0;
break;
case "minor":
minor = +1;
patch = 0;
break;
case "patch":
patch = +1;
break;
default:
break;
case "major":
major += 1;
minor = 0;
patch = 0;
break;
case "minor":
minor += 1;
patch = 0;
break;
case "patch":
patch = +1;
break;
default:
break;
}

const newContent = content
.replace(versionCodeRe, `versionCode = ${newVersionCode}`)
.replace(versionNameRe, `versionName = "${major}.${minor}.${patch}"`);
.replace(versionCodeRe, `versionCode = ${newVersionCode}`)
.replace(versionNameRe, `versionName = "${major}.${minor}.${patch}"`);

fs.writeFileSync(appGradle, newContent);

Expand Down

0 comments on commit 073afdf

Please sign in to comment.