MCPcopy Create free account
hub / github.com/anomalyco/opencode / parse

Function parse

packages/desktop/scripts/finalize-latest-json.ts:64–93  ·  view source on GitHub ↗
(text: string)

Source from the content-addressed store, hash-verified

62}
63
64function 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
95async function read(sub: string, file: string) {
96 const item = Bun.file(path.join(root, sub, file))

Callers 1

readFunction · 0.70

Calls 1

flushFunction · 0.70

Tested by

no test coverage detected