-
-
Notifications
You must be signed in to change notification settings - Fork 149
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #375 from ganeshrvel/release/3.2.23
codemagic ci to install semver fix
- Loading branch information
Showing
3 changed files
with
39 additions
and
4 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
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,36 @@ | ||
exports.semverSatisfies = (version, range) => { | ||
const [gtOp, gtVersion] = gtSemver(range); | ||
const [ltOp, ltVersion] = ltSemver(range); | ||
const versionParts = version.split('.').map(Number); | ||
const gtVersionParts = gtVersion.split('.').map(Number); | ||
const ltVersionParts = ltVersion.split('.').map(Number); | ||
|
||
// eslint-disable-next-line no-plusplus | ||
for (let i = 0; i < 3; i++) { | ||
const vp = versionParts[i] || 0; | ||
const gtvp = gtVersionParts[i] || 0; | ||
const ltvp = ltVersionParts[i] || 0; | ||
|
||
if (vp > ltvp || (vp === ltvp && ltOp === '<')) { | ||
return false; | ||
} | ||
|
||
if (vp < gtvp || (vp === gtvp && gtOp === '>')) { | ||
return false; | ||
} | ||
} | ||
|
||
return true; | ||
}; | ||
|
||
const gtSemver = (range) => { | ||
const gtPattern = />=?\s*(\d+(?:\.\d+(?:\.\d+)?)?)/.exec(range); | ||
|
||
return gtPattern ? ['>=', gtPattern[1]] : ['>=', '0.0.0']; | ||
}; | ||
|
||
const ltSemver = (range) => { | ||
const ltPattern = /<=?\s*(\d+(?:\.\d+(?:\.\d+)?)?)/.exec(range); | ||
|
||
return ltPattern ? ['<=', ltPattern[1]] : ['<=', '9999.9999.9999']; | ||
}; |