Skip to content

Commit

Permalink
chore(pub): Handle dependency types in the same order as documented
Browse files Browse the repository at this point in the history
Signed-off-by: Sebastian Schuberth <sebastian@doubleopen.org>
  • Loading branch information
sschuberth committed Oct 21, 2024
1 parent 5c27750 commit 7b1c5b9
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions plugins/package-managers/pub/src/main/kotlin/Pubspec.kt
Original file line number Diff line number Diff line change
Expand Up @@ -118,14 +118,6 @@ private object DependencyMapSerializer : KSerializer<Map<String, Dependency>> by
private fun YamlNode.decodeDependency(): Dependency {
if (this is YamlScalar) return HostedDependency(yamlScalar.content)

yamlMap.get<YamlScalar>("sdk")?.let { sdk ->
return SdkDependency(sdk = sdk.content)
}

yamlMap.get<YamlScalar>("path")?.let { path ->
return PathDependency(path = path.content)
}

yamlMap.get<YamlNode>("hosted")?.let { hosted ->
val version = checkNotNull(yamlMap.get<YamlScalar>("version")).content
val url = if (hosted is YamlMap) {
Expand All @@ -149,6 +141,14 @@ private object DependencyMapSerializer : KSerializer<Map<String, Dependency>> by
}
}

yamlMap.get<YamlScalar>("path")?.let { path ->
return PathDependency(path = path.content)
}

yamlMap.get<YamlScalar>("sdk")?.let { sdk ->
return SdkDependency(sdk = sdk.content)
}

throw SerializationException("Unexpected dependency node format.")
}
}

0 comments on commit 7b1c5b9

Please sign in to comment.