-
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
31 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import semver from 'semver' | ||
import isLegacyVersion from '@libs/isLegacyVersion' | ||
|
||
export default (previousVersion, currentVersion) => { | ||
// 新安装,没有检查到旧版本号 | ||
if (!previousVersion) return false | ||
// 检查到老的 '0.x.x.x' 版本号,但是这个不能直接传给 semver,会报错 | ||
if (isLegacyVersion(previousVersion)) return true | ||
return semver.gt(currentVersion, previousVersion) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import isExtensionUpgraded from './isExtensionUpgraded' | ||
|
||
test('isExtensionUpgraded', () => { | ||
expect(isExtensionUpgraded(null, '1.0.0')).toBe(false) | ||
expect(isExtensionUpgraded('0.9.8.9', '1.0.0')).toBe(true) | ||
expect(isExtensionUpgraded('1.0.0', '1.0.0')).toBe(false) | ||
expect(isExtensionUpgraded('1.0.0', '1.0.1')).toBe(true) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// 判断版本号是否为 '0.x.x.x' 的格式 | ||
export default version => ( | ||
typeof version === 'string' && | ||
/^0\.\d\.\d\.\d$/.test(version) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import isLegacyVersion from './isLegacyVersion' | ||
|
||
test('isLegacyVersion', () => { | ||
expect(isLegacyVersion('0.9.8.9')).toBe(true) | ||
expect(isLegacyVersion('1.0.0')).toBe(false) | ||
}) |