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

Function readFile

packages/@contentlayer/utils/src/fs-in-memory.ts:53–65  ·  view source on GitHub ↗
(filePath: string)

Source from the content-addressed store, hash-verified

51}
52
53export const readFile = (filePath: string): T.Effect<OT.HasTracer, ReadFileError | FileNotFoundError, string> =>
54 OT.withSpan('readFile', { attributes: { filePath } })(
55 T.tryCatch(
56 () => fs.readFileSync(filePath, 'utf8') as string,
57 (error: any) => {
58 if (error.code === 'ENOENT') {
59 return new FileNotFoundError({ filePath })
60 } else {
61 return new ReadFileError({ filePath, error })
62 }
63 },
64 ),
65 )
66
67export const readFileBuffer = (filePath: string): T.Effect<OT.HasTracer, ReadFileError | FileNotFoundError, Buffer> =>
68 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…