Skip to content

Commit f00c59e

Browse files
committed
feat(node): Also guess author names when missing from JsonObjects
This is a fixup for 98caf3f. Signed-off-by: Sebastian Schuberth <[email protected]>
1 parent 6c1faf0 commit f00c59e

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

plugins/package-managers/node/src/main/kotlin/PackageJson.kt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,15 @@ private object AuthorListSerializer : JsonTransformingSerializer<List<Author>>(s
183183

184184
private fun JsonElement.toAuthorObject(): List<JsonElement> =
185185
when (this) {
186-
is JsonObject -> listOf(this)
186+
is JsonObject -> when {
187+
get("name") == null -> {
188+
val name = get("email")?.let { guessNameFromEmail(it.jsonPrimitive.content) }
189+
val nameEntry = "name" to JsonPrimitive(name)
190+
listOf(JsonObject(this + nameEntry))
191+
}
192+
193+
else -> listOf(this)
194+
}
187195

188196
is JsonPrimitive -> parseAuthorString(contentOrNull).mapNotNull { info ->
189197
when {

0 commit comments

Comments
 (0)