MCPcopy Create free account
hub / github.com/contentlayerdev/contentlayer / readFile

Function readFile

packages/@contentlayer/utils/src/node/fs.ts:55–67  ·  view source on GitHub ↗
(filePath: string)

Source from the content-addressed store, hash-verified

53}
54
55const readFile = (filePath: string): T.Effect<OT.HasTracer, ReadFileError | FileNotFoundError, string> =>
56 OT.withSpan('readFile', { attributes: { filePath } })(
57 T.tryCatchPromise(
58 () => fs.readFile(filePath, 'utf8'),
59 (error: any) => {
60 if (error.code === 'ENOENT') {
61 return new FileNotFoundError({ filePath })
62 } else {
63 return new ReadFileError({ filePath, error })
64 }
65 },
66 ),
67 )
68
69const readFileBuffer = (filePath: string): T.Effect<OT.HasTracer, ReadFileError | FileNotFoundError, Buffer> =>
70 OT.withSpan('readFileBuffer', { attributes: { filePath } })(

Callers 1

readFileJsonFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…