MCPcopy Create free account
hub / github.com/alangpierce/sucrase / readJSONFileContentsIfExists

Function readJSONFileContentsIfExists

script/util/readFileContents.ts:12–22  ·  view source on GitHub ↗
(path: string)

Source from the content-addressed store, hash-verified

10
11// eslint-disable-next-line @typescript-eslint/no-explicit-any
12export async function readJSONFileContentsIfExists(path: string): Promise<any> {
13 try {
14 return JSON.parse(await readFileContents(path));
15 } catch (e) {
16 if ((e as {code: string}).code === "ENOENT") {
17 return null;
18 } else {
19 throw e;
20 }
21 }
22}

Callers 1

Calls 1

readFileContentsFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…