Skip to content

Commit a09026c

Browse files
committed
fix: handle pieces as null coming from curio import-pieces
1 parent 3536ae5 commit a09026c

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

scripts/backup-helper/commands/commit.mjs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,10 @@ function renderCommitProgress(summary) {
158158
const parkingResultSchema = z
159159
.object({
160160
count: z.number().int().nonnegative(),
161-
pieces: z.array(z.string()),
161+
pieces: z
162+
.array(z.string())
163+
.nullable()
164+
.transform((pieces) => pieces ?? []),
162165
})
163166
.refine((value) => value.count === value.pieces.length, {
164167
message: 'count must match pieces length',
@@ -193,7 +196,7 @@ async function runParkingBinary(dir, target) {
193196
throw new Error(`commit: parking command returned invalid JSON: ${err?.message || err}`)
194197
}
195198

196-
return parkingResultSchema.parse(parsed)
199+
return /** @type {ParkingResult} */ (parkingResultSchema.parse(parsed))
197200
}
198201

199202
/**

0 commit comments

Comments
 (0)