[Gradle, JS] Use when instead of pipeline of changes

#KT-37207 fixed
This commit is contained in:
Ilya Goncharov
2020-03-26 11:13:16 +03:00
parent 14af869a87
commit 201d140912
@@ -38,21 +38,20 @@ internal class YarnEntryRegistry(private val lockFile: File) {
private fun dependencyKey(packageKey: String, version: String) =
YarnLock.dependencyKey(packageKey, version).correctDependencyKey()
private fun String.correctDependencyKey(): String {
var correctedKey = replace(GITHUB_VERSION_PREFIX, "@")
private fun String.correctDependencyKey(): String =
when {
contains(GITHUB_VERSION_PREFIX) -> replace(GITHUB_VERSION_PREFIX, "@")
contains(FILE_VERSION_PREFIX) -> {
val location = substringAfter(FILE_VERSION_PREFIX)
val path = lockFile
.parentFile
.resolve(location)
.canonicalPath
if (FILE_VERSION_PREFIX in correctedKey) {
val location = correctedKey.substringAfter(FILE_VERSION_PREFIX)
val path = lockFile
.parentFile
.resolve(location)
.canonicalPath
correctedKey = correctedKey.replaceAfter(FILE_VERSION_PREFIX, path)
replaceAfter(FILE_VERSION_PREFIX, path)
}
else -> this
}
return correctedKey
}
}
private const val FILE_VERSION_PREFIX = "@file:"