fix: version update error

This commit is contained in:
GyDi 2022-01-12 22:19:44 +08:00
parent 0f5d2b15e0
commit 4e8d4f4591

View File

@ -11,10 +11,16 @@ async function resolvePublish() {
let [a, b, c] = packageJson.version.split(".").map(Number); let [a, b, c] = packageJson.version.split(".").map(Number);
if (flag === "major") a += 1; if (flag === "major") {
else if (flag === "minor") b += 1; a += 1;
else if (flag === "patch") c += 1; b = 0;
else throw new Error(`invalid flag "${flag}"`); c = 0;
} else if (flag === "minor") {
b += 1;
c = 0;
} else if (flag === "patch") {
c += 1;
} else throw new Error(`invalid flag "${flag}"`);
const nextVersion = `${a}.${b}.${c}`; const nextVersion = `${a}.${b}.${c}`;
packageJson.version = nextVersion; packageJson.version = nextVersion;