Skip to content

Commit 69bd6dc

Browse files
committed
fix(ci): reduce api payload renderer complexity
1 parent 8e721d3 commit 69bd6dc

1 file changed

Lines changed: 12 additions & 8 deletions

File tree

packages/app/src/docker-git/api-json.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,15 @@ const renderNestedStatusPayload = (
116116
return readNestedMessage(object, "status") ?? JSON.stringify(payload, null, 2)
117117
}
118118

119+
const renderDirectObjectPayload = (object: JsonObject): string | null => {
120+
const directStatus = renderGithubStatusLike(object)
121+
if (directStatus !== null) {
122+
return directStatus
123+
}
124+
125+
return asString(object["message"])
126+
}
127+
119128
export const renderJsonPayload = (payload: JsonValue): string => {
120129
if (typeof payload === "string") {
121130
return payload
@@ -126,14 +135,9 @@ export const renderJsonPayload = (payload: JsonValue): string => {
126135
return JSON.stringify(payload, null, 2)
127136
}
128137

129-
const directStatus = renderGithubStatusLike(object)
130-
if (directStatus !== null) {
131-
return directStatus
132-
}
133-
134-
const message = asString(object["message"])
135-
if (message !== null) {
136-
return message
138+
const directPayload = renderDirectObjectPayload(object)
139+
if (directPayload !== null) {
140+
return directPayload
137141
}
138142

139143
const nestedStatus = renderNestedStatusPayload(payload, object)

0 commit comments

Comments
 (0)