diff --git a/src/inputs/run-install.ts b/src/inputs/run-install.ts index e4858cf..d7215b7 100644 --- a/src/inputs/run-install.ts +++ b/src/inputs/run-install.ts @@ -2,37 +2,28 @@ import { getInput, error } from '@actions/core' import * as yaml from 'yaml' import { z, ZodError } from 'zod' -export interface RunInstall { - readonly recursive?: boolean - readonly cwd?: string - readonly args?: readonly string[] -} - -const zRunInstall = z.object({ +const RunInstallSchema = z.object({ recursive: z.boolean().optional(), cwd: z.string().optional(), args: z.array(z.string()).optional(), }) -export type RunInstallInput = - | null - | boolean - | RunInstall - | RunInstall[] - -const zRunInstallInput = z.union([ +const RunInstallInputSchema = z.union([ z.null(), z.boolean(), - zRunInstall, - z.array(zRunInstall), + RunInstallSchema, + z.array(RunInstallSchema), ]) +export type RunInstallInput = z.infer +export type RunInstall = z.infer + export function parseRunInstall(inputName: string): RunInstall[] { const input = getInput(inputName, { required: true }) const parsedInput: unknown = yaml.parse(input) try { - const result: RunInstallInput = zRunInstallInput.parse(parsedInput) + const result: RunInstallInput = RunInstallInputSchema.parse(parsedInput) if (!result) return [] if (result === true) return [{ recursive: true }] if (Array.isArray(result)) return result