| 62 | } |
| 63 | |
| 64 | function parse(text: string): Yml { |
| 65 | const lines = text.split("\n") |
| 66 | let version = "" |
| 67 | const files: Item[] = [] |
| 68 | let url = "" |
| 69 | |
| 70 | const flush = () => { |
| 71 | if (!url) return |
| 72 | files.push({ url }) |
| 73 | url = "" |
| 74 | } |
| 75 | |
| 76 | for (const line of lines) { |
| 77 | const trim = line.trim() |
| 78 | if (line.startsWith("version:")) { |
| 79 | version = line.slice("version:".length).trim() |
| 80 | continue |
| 81 | } |
| 82 | if (trim.startsWith("- url:")) { |
| 83 | flush() |
| 84 | url = trim.slice("- url:".length).trim() |
| 85 | continue |
| 86 | } |
| 87 | const indented = line.startsWith(" ") || line.startsWith("\t") |
| 88 | if (!indented) flush() |
| 89 | } |
| 90 | flush() |
| 91 | |
| 92 | return { version, files } |
| 93 | } |
| 94 | |
| 95 | async function read(sub: string, file: string) { |
| 96 | const item = Bun.file(path.join(root, sub, file)) |