Skip to content

Commit c43566b

Browse files
author
berkay.daglar
committed
fix(diff): fix prerelease to stable version diff logic
Refactored version diff logic to handle transitions from prerelease versions to stable versions correctly for major/minor/patch version bumps.
1 parent 868d4bb commit c43566b

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

functions/diff.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,16 @@ const diff = (version1, version2) => {
2929

3030
// Otherwise it can be determined by checking the high version
3131

32-
if (highVersion.patch) {
33-
// anything higher than a patch bump would result in the wrong version
34-
return 'patch'
35-
}
36-
3732
if (highVersion.minor) {
3833
// anything higher than a minor bump would result in the wrong version
3934
return 'minor'
4035
}
4136

37+
if (highVersion.patch) {
38+
// anything higher than a patch bump would result in the wrong version
39+
return 'patch'
40+
}
41+
4242
// bumping major/minor/patch all have same result
4343
return 'major'
4444
}

test/functions/diff.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ test('diff versions test', (t) => {
3434
['1.0.0-1', '2.0.0-1', 'premajor'],
3535
['1.0.0-1', '1.1.0-1', 'preminor'],
3636
['1.0.0-1', '1.0.1-1', 'prepatch'],
37+
['1.7.2-1', '1.8.1', 'minor'],
3738
].forEach((v) => {
3839
const version1 = v[0]
3940
const version2 = v[1]

0 commit comments

Comments
 (0)