[Gradle, JS] KT-37207 Move File prefix to NpmDependency.kt
This commit is contained in:
+3
-2
@@ -17,7 +17,6 @@ import org.gradle.api.tasks.TaskDependency
|
|||||||
import org.gradle.internal.component.local.model.DefaultLibraryBinaryIdentifier
|
import org.gradle.internal.component.local.model.DefaultLibraryBinaryIdentifier
|
||||||
import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootPlugin
|
import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootPlugin
|
||||||
import org.jetbrains.kotlin.gradle.targets.js.npm.resolved.KotlinCompilationNpmResolution
|
import org.jetbrains.kotlin.gradle.targets.js.npm.resolved.KotlinCompilationNpmResolution
|
||||||
import org.jetbrains.kotlin.gradle.utils.relativeToRoot
|
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
data class NpmDependency(
|
data class NpmDependency(
|
||||||
@@ -135,4 +134,6 @@ data class NpmDependency(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun getReason(): String? = reason
|
override fun getReason(): String? = reason
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const val FILE_VERSION_PREFIX = "file:"
|
||||||
+9
-6
@@ -6,6 +6,7 @@
|
|||||||
package org.jetbrains.kotlin.gradle.targets.js.yarn
|
package org.jetbrains.kotlin.gradle.targets.js.yarn
|
||||||
|
|
||||||
import com.github.gundy.semver4j.SemVer
|
import com.github.gundy.semver4j.SemVer
|
||||||
|
import org.jetbrains.kotlin.gradle.targets.js.npm.FILE_VERSION_PREFIX
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
internal class YarnEntryRegistry(private val lockFile: File) {
|
internal class YarnEntryRegistry(private val lockFile: File) {
|
||||||
@@ -40,19 +41,21 @@ internal class YarnEntryRegistry(private val lockFile: File) {
|
|||||||
|
|
||||||
private fun String.correctDependencyKey(): String =
|
private fun String.correctDependencyKey(): String =
|
||||||
when {
|
when {
|
||||||
GITHUB_VERSION_PREFIX in this -> replace(GITHUB_VERSION_PREFIX, "@")
|
GITHUB_MARKER in this -> replace(GITHUB_MARKER, SEPARATOR)
|
||||||
FILE_VERSION_PREFIX in this -> {
|
FILE_MARKER in this -> {
|
||||||
val location = substringAfter(FILE_VERSION_PREFIX)
|
val location = substringAfter(FILE_MARKER)
|
||||||
val path = lockFile
|
val path = lockFile
|
||||||
.parentFile
|
.parentFile
|
||||||
.resolve(location)
|
.resolve(location)
|
||||||
.canonicalPath
|
.canonicalPath
|
||||||
|
|
||||||
replaceAfter(FILE_VERSION_PREFIX, path)
|
replaceAfter(FILE_MARKER, path)
|
||||||
}
|
}
|
||||||
else -> this
|
else -> this
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private const val FILE_VERSION_PREFIX = "@file:"
|
private const val SEPARATOR = "@"
|
||||||
private const val GITHUB_VERSION_PREFIX = "@github:"
|
|
||||||
|
private const val FILE_MARKER = "${SEPARATOR}$FILE_VERSION_PREFIX"
|
||||||
|
private const val GITHUB_MARKER = "${SEPARATOR}github:"
|
||||||
Reference in New Issue
Block a user