-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Correct minVersion required (#15)
* fix minVersion required * x
- Loading branch information
Showing
2 changed files
with
18 additions
and
6 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 |
---|---|---|
@@ -1,8 +1,16 @@ | ||
// ** does not handee '- name' | ||
export function assertMinVersion(version: string, minRequired: string) { | ||
const minArr = minRequired.split("."); | ||
return version.split(".").every((v, i) => { | ||
if (i < 3 && +v >= +minArr[i]) return true; | ||
return false; | ||
}); | ||
const minArr = minRequired.split(".").map((v) => +v); | ||
const versionArr = version.split(".").map((v) => +v); | ||
|
||
// compare major | ||
if (versionArr[0] < minArr[0]) return false; | ||
if (versionArr[0] > minArr[0]) return true; | ||
|
||
// compare minor | ||
if (versionArr[1] < minArr[1]) return false; | ||
if (versionArr[1] > minArr[1]) return true; | ||
|
||
// compare patch | ||
if (versionArr[2] < minArr[2]) return false; | ||
return true; | ||
} |