MCPcopy Create free account
hub / github.com/vercel/vercel / readFileIfExists

Function readFileIfExists

packages/python-analysis/src/util/fs.ts:15–25  ·  view source on GitHub ↗
(file: Path)

Source from the content-addressed store, hash-verified

13export type Path = AbsPath | RelPath;
14
15export async function readFileIfExists(file: Path): Promise<Buffer | null> {
16 try {
17 return await readFile(file);
18 } catch (error: unknown) {
19 if (!isErrnoException(error, 'ENOENT')) {
20 throw error;
21 }
22 }
23
24 return null;
25}
26
27export async function readFileTextIfExists(
28 file: Path,

Callers 1

readFileTextIfExistsFunction · 0.85

Calls 2

isErrnoExceptionFunction · 0.90
readFileFunction · 0.50

Tested by

no test coverage detected