Skip to content

Commit

Permalink
[eas-build-job] Switch preprocess to union+transform (#509)
Browse files Browse the repository at this point in the history
# Why

A union works better for generating JSON schema later, because Zod is able to infer better what is the expected input.

# How

Instead of preprocessing input, we're going to transform it after parsing.

# Test Plan

Tests should pass.
  • Loading branch information
sjchmiela authored Feb 6, 2025
1 parent c5cd63a commit df82e68
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions packages/eas-build-job/src/step.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,19 +127,14 @@ export const ShellStepZ = CommonStepZ.extend({
*/
outputs: z
.array(
z.preprocess(
(input) => {
// We allow a shorthand for outputs
if (typeof input === 'string') {
return { name: input, required: false };
}
return input;
},
z.union([
// We allow a shorthand for outputs
z.string().transform((name) => ({ name, required: false })),
z.object({
name: z.string(),
required: z.boolean().optional(),
})
)
}),
])
)
.optional(),

Expand Down

0 comments on commit df82e68

Please sign in to comment.