Skip to content

Commit

Permalink
Revert "fix: version test for equal pre-release versions"
Browse files Browse the repository at this point in the history
This reverts commit 2613b71.
  • Loading branch information
vaind committed Feb 28, 2024
1 parent 55f9ab3 commit 0963065
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 23 deletions.
19 changes: 0 additions & 19 deletions src/utils/__tests__/version.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,25 +195,6 @@ describe('versionGreaterOrEqualThan', () => {
expect(() => versionGreaterOrEqualThan(v1, v2)).toThrowError();
expect(() => versionGreaterOrEqualThan(v2, v1)).toThrowError();
});

test('can compare pre parts that are the same', () => {
let v1 = parseVersion('1.2.3-dev.0')!;
let v2 = parseVersion('1.2.3-dev.0')!;
expect(versionGreaterOrEqualThan(v1, v2)).toBe(true);
expect(versionGreaterOrEqualThan(v2, v1)).toBe(true);

v1 = parseVersion('1.2.3-dev.0+A')!;
v2 = parseVersion('1.2.3-dev.0+A')!;
expect(versionGreaterOrEqualThan(v1, v2)).toBe(true);
expect(versionGreaterOrEqualThan(v2, v1)).toBe(true);
});

test('can compare pre parts that are the same but have different builds', () => {
const v1 = parseVersion('1.2.3-dev.0+buildA')!;
const v2 = parseVersion('1.2.3-dev.0+buildB')!;
expect(versionGreaterOrEqualThan(v1, v2)).toBe(false);
expect(versionGreaterOrEqualThan(v2, v1)).toBe(false);
});
});

describe('getPackage', () => {
Expand Down
7 changes: 3 additions & 4 deletions src/utils/version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,6 @@ export function versionGreaterOrEqualThan(v1: SemVer, v2: SemVer): boolean {
return true;
} else if (v1.pre && !v2.pre) {
return false;
} else if (v1.pre && v2.pre && v1.pre === v2.pre) {
return v1.build === v2.build;
} else if (v1.pre && v2.pre && v1.pre !== v2.pre && /^\d+$/.test(v1.pre) && /^\d+$/.test(v2.pre)) {
return v1.pre > v2.pre;
} else if (v1.build || v2.build || v1.pre || v2.pre) {
Expand Down Expand Up @@ -159,6 +157,7 @@ export function getPackageVersion(): string {
* Returns the stringified version of the passed SemVer object.
*/
export function semVerToString(s: SemVer) {
return `${s.major}.${s.minor}.${s.patch}${s.pre ? `-${s.pre}` : ''}${s.build ? `+${s.build}` : ''
}`;
return `${s.major}.${s.minor}.${s.patch}${s.pre ? `-${s.pre}` : ''}${
s.build ? `+${s.build}` : ''
}`;
}

0 comments on commit 0963065

Please sign in to comment.