How to use the cmp function from semver
Find comprehensive JavaScript semver.cmp code examples handpicked from public code repositorys.
GitHub: tars/tars-cli
33 34 35 36 37 38 39 40 41 42
function getNewComponentPath(customPath) { let newComponentPath = `${cwd}/markup/${componentsFolderName}/`; // Path to new component. Includes component name if (customPath && semver.cmp(currentTarsVersion, '>=', '1.8.0')) { newComponentPath += `${customPath}/${newComponentName}`; } else { newComponentPath += newComponentName; }
28
105
15
78 79 80 81 82 83 84 85 86 87
if (semver.cmp(version, operators[0], specifiedVersions[0])) { this.result[depName] = `${depVersion}`; break; } } else if (operators.length > 1 && specifiedVersions.length > 1) { if (semver.cmp(version, operators[0], specifiedVersions[0]) && semver.cmp(version, operators[1], specifiedVersions[1])) { this.result[depName] = `${depVersion}`; break; } }
8
20
2
GitHub: tidev/node-appc
167 168 169 170 171 172 173 174 175 176
const range = new semver.Range(str); for (let i = 0; i < range.set.length; i++) { const set = range.set[i]; for (let j = set.length - 1; j >= 0; j--) { if (set[j].semver instanceof semver.SemVer) { // console.log(ver, set[j].operator, set[j].semver, semver.cmp(ver, set[j].operator, set[j].semver, set[j].loose)); if ((set[j].operator === '<' || set[j].operator === '<=') && !semver.cmp(ver, set[j].operator, set[j].semver, set[j].loose)) { return 'maybe'; } break;
29
11
53
42 43 44 45 46 47 48 49 50 51
rules.cmp = { method: function (cmp, exp) { return this.$_addRule({ name: 'cmp', args: { cmp, exp } }) }, validate: function (value, helpers, { cmp, exp }) { return semver.cmp(value, cmp, exp) ? value : helpers.error(`${extensionName}.cmp`, { cmp, exp }) }, args: [ { name: 'cmp',
4
7
3
GitHub: megawac/SemVish
57 58 59 60 61 62 63 64 65 66
return SemVer[semverFunc](SemVish(a, loose), SemVish(b, loose), loose); }; }); SemVish.cmp = function(a, op, b, loose) { return SemVer.cmp(SemVish(a, loose), op, SemVish(b, loose), loose); }; SemVish.clean = function(version, loose) { try {
1
5
2
semver.gte is the most popular function in semver (528 examples)