Skip to content

Commit

Permalink
refactor(manager/pep621): simplify zod schema for parsing pdm.lock (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Churro committed Mar 5, 2024
1 parent 1d4972c commit ec572f8
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions lib/modules/manager/pep621/schema.ts
Expand Up @@ -61,14 +61,16 @@ export const PyProjectSchema = z.object({
export const PdmLockfileSchema = Toml.pipe(
z.object({
package: LooseArray(
z
.object({
name: z.string(),
version: z.string(),
})
.transform(({ name, version }): [string, string] => [name, version]),
)
.transform((entries) => Object.fromEntries(entries))
.catch({}),
z.object({
name: z.string(),
version: z.string(),
}),
),
}),
).transform(({ package: lock }) => ({ lock }));
)
.transform(({ package: pkg }) =>
Object.fromEntries(
pkg.map(({ name, version }): [string, string] => [name, version]),
),
)
.transform((lock) => ({ lock }));

0 comments on commit ec572f8

Please sign in to comment.