MCPcopy
hub / github.com/EveryInc/compound-engineering-plugin / readJsonObjectSafe

Function readJsonObjectSafe

src/utils/json-config.ts:29–47  ·  view source on GitHub ↗
(configPath: string)

Source from the content-addressed store, hash-verified

27}
28
29async function readJsonObjectSafe(configPath: string): Promise<JsonObject> {
30 if (!(await pathExists(configPath))) {
31 return {}
32 }
33
34 try {
35 const parsed = await readJson<unknown>(configPath)
36 if (isJsonObject(parsed)) {
37 return parsed
38 }
39 } catch {
40 // Fall through to warning and replacement.
41 }
42
43 console.warn(
44 `Warning: existing ${path.basename(configPath)} could not be parsed and will be replaced.`,
45 )
46 return {}
47}

Callers 1

mergeJsonConfigAtKeyFunction · 0.85

Calls 2

pathExistsFunction · 0.90
isJsonObjectFunction · 0.85

Tested by

no test coverage detected