MCPcopy
hub / github.com/inkeep/open-knowledge / loadYamlFile

Function loadYamlFile

packages/cli/src/config/loader.ts:48–73  ·  view source on GitHub ↗
(filePath: string)

Source from the content-addressed store, hash-verified

46}
47
48function loadYamlFile(filePath: string): LoadedYamlFile {
49 if (!existsSync(filePath)) {
50 return { value: null, path: filePath, source: null, doc: null };
51 }
52 let raw: string;
53 try {
54 raw = readFileSync(filePath, 'utf-8');
55 } catch (err) {
56 console.warn(
57 `[config] Failed to read ${filePath}: ${err instanceof Error ? err.message : err}`,
58 );
59 return { value: null, path: filePath, source: null, doc: null };
60 }
61 const doc = parseDocument(raw);
62 if (doc.errors.length > 0) {
63 console.warn(
64 `[config] Failed to parse ${filePath}: ${doc.errors.map((e) => e.message).join('; ')}`,
65 );
66 return { value: null, path: filePath, source: raw, doc: null };
67 }
68 const parsed = doc.toJSON();
69 if (isObject(parsed)) {
70 return { value: parsed, path: filePath, source: raw, doc };
71 }
72 return { value: null, path: filePath, source: raw, doc };
73}
74
75function annotateIssuesWithSource(
76 zodIssues: ReadonlyArray<{ path: PropertyKey[]; message: string; code: string }>,

Callers 1

loadConfigFunction · 0.85

Calls 3

isObjectFunction · 0.90
mapMethod · 0.80
warnMethod · 0.65

Tested by

no test coverage detected