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? {