1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-30 10:36:35 +02:00

Tools: Fixed Cli version handling

This commit is contained in:
Laurent Cozic 2020-09-21 12:16:05 +01:00
parent 9610b7e6bd
commit ce3bd2a47d

View File

@ -249,12 +249,23 @@ function capitalizeFirstLetter(string) {
function decreaseTagVersion(tag) {
const s = tag.split('.');
const lastToken = s.pop();
const s2 = lastToken.split('-');
let num = Number(s2[0]);
num--;
if (num < 0) throw new Error(`Cannot decrease tag version: ${tag}`);
s.push(`${num}`);
let updated = false;
for (let tokenIndex = s.length - 1; tokenIndex >= 0; tokenIndex--) {
const token = s[tokenIndex];
const s2 = token.split('-');
let num = Number(s2[0]);
num--;
if (num >= 0) {
updated = true;
s[tokenIndex] = num;
break;
}
}
if (!updated) throw new Error(`Cannot decrease tag version: ${tag}`);
return s.join('.');
}