* Returns the highest semver definition that satisfies all versions * in the given list. * @param {String[]} versions The list of semver version ranges. * @param {String} baseVersion The base version of which higher versions should be * determined; as a version (1.2.3), not a range (>=1.
({ versions, baseVersion })
| 109 | * @returns {String} The highest semver version. |
| 110 | */ |
| 111 | getHigherVersions({ versions, baseVersion }) { |
| 112 | // Add min satisfying node versions |
| 113 | const minVersions = versions.map(v => { |
| 114 | v.nodeMinVersion = semver.minVersion(v.nodeVersion) |
| 115 | return v; |
| 116 | }); |
| 117 | |
| 118 | // Sort by min version |
| 119 | const sortedMinVersions = minVersions.sort((v1, v2) => semver.compare(v1.nodeMinVersion, v2.nodeMinVersion)); |
| 120 | |
| 121 | // Filter by higher versions |
| 122 | const higherVersions = sortedMinVersions.filter(v => semver.gt(v.nodeMinVersion, baseVersion)); |
| 123 | // console.log(`getHigherVersions: ${JSON.stringify(higherVersions)}`); |
| 124 | return higherVersions; |
| 125 | } |
| 126 | |
| 127 | /** |
| 128 | * Returns the node version of the parent package. |