From 4e8d4f45918703dab8d24ecaaf40ee761a5c7563 Mon Sep 17 00:00:00 2001 From: GyDi Date: Wed, 12 Jan 2022 22:19:44 +0800 Subject: [PATCH] fix: version update error --- scripts/publish.mjs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/scripts/publish.mjs b/scripts/publish.mjs index f22119d..6c2e471 100644 --- a/scripts/publish.mjs +++ b/scripts/publish.mjs @@ -11,10 +11,16 @@ async function resolvePublish() { let [a, b, c] = packageJson.version.split(".").map(Number); - if (flag === "major") a += 1; - else if (flag === "minor") b += 1; - else if (flag === "patch") c += 1; - else throw new Error(`invalid flag "${flag}"`); + if (flag === "major") { + a += 1; + b = 0; + 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}`; packageJson.version = nextVersion;