[Gradle, JS] Introduce semver satisfying for comparison with wildcard

This commit is contained in:
Ilya Goncharov
2020-03-24 13:27:58 +03:00
parent 5441685cb4
commit 19afcd7b6b
2 changed files with 6 additions and 1 deletions
@@ -49,6 +49,7 @@ dependencies {
compile("com.google.code.gson:gson:${rootProject.extra["versions.jar.gson"]}")
compile("de.undercouch:gradle-download-task:4.0.2")
implementation("com.github.gundy:semver4j:0.16.4")
compileOnly("com.android.tools.build:gradle:2.0.0")
compileOnly("com.android.tools.build:gradle-core:2.0.0")
@@ -5,6 +5,7 @@
package org.jetbrains.kotlin.gradle.targets.js.yarn
import com.github.gundy.semver4j.SemVer
import org.gradle.api.Project
import org.jetbrains.kotlin.gradle.internal.execWithProgress
import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootPlugin
@@ -156,7 +157,10 @@ private class YarnEntryRegistry(lockFile: File) {
if (entry == null && version == "*") {
val searchKey = dependencyKey(packageKey, "")
entry = entryMap.entries
.firstOrNull { it.key.startsWith(searchKey) }
.filter { it.key.startsWith(searchKey) }
.firstOrNull {
SemVer.satisfies(it.key.removePrefix(searchKey), "*")
}
?.value
}