MCPcopy Create free account
hub / github.com/ForestHubAI/edge-agents / readComponentJson

Function readComponentJson

ts/workflow-cli/cli/deploy/components.ts:32–48  ·  view source on GitHub ↗
(dir: string)

Source from the content-addressed store, hash-verified

30// Reads and parses <dir>/component.json. Throws a path-tagged error on a missing
31// file or malformed JSON, for the caller to turn into a clean exit.
32export async function readComponentJson(dir: string): Promise<unknown> {
33 const file = path.join(dir, "component.json");
34 let raw: string;
35 try {
36 raw = await fs.readFile(file, "utf-8");
37 } catch (err) {
38 if ((err as NodeJS.ErrnoException).code === "ENOENT") {
39 throw new Error(`custom component: no component.json in ${dir}`, { cause: err });
40 }
41 throw err;
42 }
43 try {
44 return JSON.parse(raw);
45 } catch (err) {
46 throw new Error(`${file}: invalid JSON: ${err instanceof Error ? err.message : String(err)}`, { cause: err });
47 }
48}
49
50let cachedValidator: ValidateFunction | undefined;
51

Callers 2

loadFlagComponentsFunction · 0.90
promptCustomComponentsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected