MCPcopy Index your code
hub / github.com/anomalyco/models.dev / loadLabMetadata

Function loadLabMetadata

packages/web/src/render.tsx:1598–1622  ·  view source on GitHub ↗
(root: string)

Source from the content-addressed store, hash-verified

1596}
1597
1598function loadLabMetadata(root: string) {
1599 const result = new Map<string, { description?: string }>();
1600 const labsPath = path.join(root, "labs");
1601 if (!existsSync(labsPath)) return result;
1602
1603 for (const labId of readdirSync(labsPath)) {
1604 const metadataPath = path.join(labsPath, labId, "lab.toml");
1605 if (!existsSync(metadataPath)) continue;
1606
1607 const metadata = Bun.TOML.parse(readFileSync(metadataPath, "utf8")) as Record<
1608 string,
1609 unknown
1610 >;
1611 if (
1612 metadata.description !== undefined &&
1613 (typeof metadata.description !== "string" || metadata.description.length === 0)
1614 ) {
1615 throw new Error(`Invalid lab description in ${metadataPath}`);
1616 }
1617
1618 result.set(labId, { description: metadata.description });
1619 }
1620
1621 return result;
1622}
1623
1624function minDefined(values: Array<number | undefined>) {
1625 let result: number | undefined;

Callers 1

render.tsxFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected