Skip to content

Commit 8e721d3

Browse files
committed
fix(ci): reduce api json render complexity
1 parent 5c2a977 commit 8e721d3

1 file changed

Lines changed: 19 additions & 6 deletions

File tree

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

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,23 @@ const readNestedMessage = (
9999
return asString(nested["message"])
100100
}
101101

102+
const renderNestedStatusPayload = (
103+
payload: JsonValue,
104+
object: JsonObject
105+
): string | null => {
106+
const nestedStatus = asObject(object["status"])
107+
if (nestedStatus === null) {
108+
return null
109+
}
110+
111+
const renderedNestedStatus = renderGithubStatusLike(nestedStatus)
112+
if (renderedNestedStatus !== null) {
113+
return renderedNestedStatus
114+
}
115+
116+
return readNestedMessage(object, "status") ?? JSON.stringify(payload, null, 2)
117+
}
118+
102119
export const renderJsonPayload = (payload: JsonValue): string => {
103120
if (typeof payload === "string") {
104121
return payload
@@ -119,13 +136,9 @@ export const renderJsonPayload = (payload: JsonValue): string => {
119136
return message
120137
}
121138

122-
const nestedStatus = asObject(object["status"])
139+
const nestedStatus = renderNestedStatusPayload(payload, object)
123140
if (nestedStatus !== null) {
124-
const renderedNestedStatus = renderGithubStatusLike(nestedStatus)
125-
if (renderedNestedStatus !== null) {
126-
return renderedNestedStatus
127-
}
128-
return readNestedMessage(object, "status") ?? JSON.stringify(payload, null, 2)
141+
return nestedStatus
129142
}
130143

131144
const nestedErrorMessage = readNestedMessage(object, "error")

0 commit comments

Comments
 (0)