[Gradle, JS] Add includedRange with version only

This commit is contained in:
Ilya Goncharov
2020-09-29 16:29:01 +03:00
parent 3075de917b
commit da16b8e527
3 changed files with 11 additions and 4 deletions
@@ -19,6 +19,15 @@ fun versionToNpmRanges(version: String): Set<NpmRange> {
.visit(parser.rangeSet())!!
}
fun includedRange(
includedVersion: String,
includedWithCaret: Boolean = false
): NpmRange =
includedRange(
listOf(includedVersion),
includedWithCaret
)
fun includedRange(
includedVersions: List<String>,
includedWithCaret: Boolean = false
@@ -157,7 +157,7 @@ private fun chooseVersion(
return newVersion
}
return (includedRange(listOf(oldVersion)) intersect includedRange(listOf(newVersion)))?.toString()
return (includedRange(oldVersion) intersect includedRange(newVersion))?.toString()
?: throw GradleException(
"""
There is already declared version of '$module' with version '$oldVersion' which does not intersects with another declared version '${newVersion}'
@@ -24,14 +24,12 @@ internal class YarnEntryRegistry(private val lockFile: File) {
return entry
}
val versionRange = includedRange(listOf(version))
entryMap.entries
.firstOrNull { (_, entry) ->
if (entry.version == null) {
false
} else {
(versionRange intersect includedRange(listOf(entry.version))) != null
(includedRange(version) intersect includedRange(entry.version)) != null
}
}
?.let { return it.value }