MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / readSourceText

Function readSourceText

src/file-limits.ts:48–57  ·  view source on GitHub ↗
(file: string, encoding: BufferEncoding = 'utf-8')

Source from the content-addressed store, hash-verified

46 * open itself. Throws what a failed open or read throws.
47 */
48export function readSourceText(file: string, encoding: BufferEncoding = 'utf-8'): string | null {
49 const fd = fs.openSync(file, fs.constants.O_RDONLY | (fs.constants.O_NONBLOCK ?? 0));
50 try {
51 const stats = fs.fstatSync(fd);
52 if (!stats.isFile() || stats.size > MAX_SOURCE_FILE_SIZE_BYTES) return null;
53 return fs.readFileSync(fd, encoding);
54 } finally {
55 fs.closeSync(fd);
56 }
57}
58
59/**
60 * The longest run of name characters a pattern is given as written. No name,

Callers 4

readPackageJsonFunction · 0.90
readFileCachedMethod · 0.90
scanFileMethod · 0.90
readTextFunction · 0.90

Calls 1

openSyncMethod · 0.45

Tested by

no test coverage detected