[Gradle, JS] Add includedRange with version only
This commit is contained in:
+9
@@ -19,6 +19,15 @@ fun versionToNpmRanges(version: String): Set<NpmRange> {
|
|||||||
.visit(parser.rangeSet())!!
|
.visit(parser.rangeSet())!!
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun includedRange(
|
||||||
|
includedVersion: String,
|
||||||
|
includedWithCaret: Boolean = false
|
||||||
|
): NpmRange =
|
||||||
|
includedRange(
|
||||||
|
listOf(includedVersion),
|
||||||
|
includedWithCaret
|
||||||
|
)
|
||||||
|
|
||||||
fun includedRange(
|
fun includedRange(
|
||||||
includedVersions: List<String>,
|
includedVersions: List<String>,
|
||||||
includedWithCaret: Boolean = false
|
includedWithCaret: Boolean = false
|
||||||
|
|||||||
+1
-1
@@ -157,7 +157,7 @@ private fun chooseVersion(
|
|||||||
return newVersion
|
return newVersion
|
||||||
}
|
}
|
||||||
|
|
||||||
return (includedRange(listOf(oldVersion)) intersect includedRange(listOf(newVersion)))?.toString()
|
return (includedRange(oldVersion) intersect includedRange(newVersion))?.toString()
|
||||||
?: throw GradleException(
|
?: throw GradleException(
|
||||||
"""
|
"""
|
||||||
There is already declared version of '$module' with version '$oldVersion' which does not intersects with another declared version '${newVersion}'
|
There is already declared version of '$module' with version '$oldVersion' which does not intersects with another declared version '${newVersion}'
|
||||||
|
|||||||
+1
-3
@@ -24,14 +24,12 @@ internal class YarnEntryRegistry(private val lockFile: File) {
|
|||||||
return entry
|
return entry
|
||||||
}
|
}
|
||||||
|
|
||||||
val versionRange = includedRange(listOf(version))
|
|
||||||
|
|
||||||
entryMap.entries
|
entryMap.entries
|
||||||
.firstOrNull { (_, entry) ->
|
.firstOrNull { (_, entry) ->
|
||||||
if (entry.version == null) {
|
if (entry.version == null) {
|
||||||
false
|
false
|
||||||
} else {
|
} else {
|
||||||
(versionRange intersect includedRange(listOf(entry.version))) != null
|
(includedRange(version) intersect includedRange(entry.version)) != null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?.let { return it.value }
|
?.let { return it.value }
|
||||||
|
|||||||
Reference in New Issue
Block a user