Skip to content

Commit

Permalink
fix: fix versionCross error (#314)
Browse files Browse the repository at this point in the history
Signed-off-by: moweiwei <mo.weiwei@99cloud.net>

Signed-off-by: moweiwei <mo.weiwei@99cloud.net>
  • Loading branch information
moweiwei authored Dec 5, 2022
1 parent 2af56d5 commit d1d52de
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ export const versionCross = (currentVersion = '', crossVersion = '') => {
const [x, y] = current;
const [x1, y1] = cross;

if ((x === x1 && y1 > y) || x1 > x) {
if ((x === x1 && Number(y1) > Number(y) + 1) || Number(x1) > Number(x)) {
return true;
}

Expand Down
8 changes: 8 additions & 0 deletions src/utils/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {
firstUpperCase,
getNoValue,
getGBValue,
versionCross,
} from './index';

describe('test utils index.js', () => {
Expand Down Expand Up @@ -131,4 +132,11 @@ describe('test utils index.js', () => {
expect(getGBValue('')).toBe('');
expect(getGBValue(0)).toBe('');
});

it('versionCross', () => {
expect(versionCross('v1.23.1', 'v1.23.6')).toBe(false);
expect(versionCross('v1.23.1', 'v1.24.6')).toBe(false);
expect(versionCross('v1.23.1', 'v1.25.6')).toBe(true);
expect(versionCross('v1.23.1', 'v2.23.1')).toBe(true);
});
});

0 comments on commit d1d52de

Please sign in to comment.