From 9bb49ac370a232ccfa801cdda75a3a75c15cc32b Mon Sep 17 00:00:00 2001 From: Ilya Goncharov Date: Tue, 4 Aug 2020 17:58:25 +0300 Subject: [PATCH] [Gradle, JS] Union of Npm Ranges ^KT-41054 fixed --- .../jetbrains/kotlin/gradle/targets/js/npm/NpmRange.kt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/NpmRange.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/NpmRange.kt index 34357fdb0f9..105326dd651 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/NpmRange.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/NpmRange.kt @@ -19,7 +19,9 @@ val NONE_RANGE = NpmRange( .toSemVer() ) -infix fun NpmRange.or(other: NpmRange): List { +infix fun NpmRange.union(other: NpmRange): List { + if (!isIntersect(other)) return listOf(this, other) + val startVersion = min(this.startVersion, other.startVersion) val endVersion = max(this.endVersion, other.endVersion) @@ -29,7 +31,9 @@ infix fun NpmRange.or(other: NpmRange): List { startInclusive = if (startVersion == other.startVersion) other.startInclusive else this.startInclusive, endVersion = endVersion, endInclusive = if (startVersion == other.startVersion) other.startInclusive else this.startInclusive - ) + ).let { + listOf(it) + } } infix fun NpmRange.intersect(other: NpmRange): NpmRange? {