Initial commit
This commit is contained in:
commit
4e31f18045
15 changed files with 779 additions and 0 deletions
19
src/binding.ts
Normal file
19
src/binding.ts
Normal file
|
@ -0,0 +1,19 @@
|
|||
import YAML from "yaml";
|
||||
import z from "zod";
|
||||
|
||||
const BindingSchema = z.object({
|
||||
id: z.string(),
|
||||
playbill: z.string().default("Unnamed playbill"),
|
||||
author: z.string().optional(),
|
||||
version: z.number(),
|
||||
files: z.array(z.string()).default(["**/*.yaml"]),
|
||||
});
|
||||
|
||||
type Binding = z.infer<typeof BindingSchema>;
|
||||
|
||||
export async function loadBindingFile(filePath: string): Promise<Binding> {
|
||||
const file = Bun.file(filePath);
|
||||
const text = await file.text();
|
||||
const parsed = YAML.parse(text);
|
||||
return BindingSchema.parse(parsed);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue