MCPcopy
hub / github.com/compiler-explorer/compiler-explorer / tryReadTextFile

Function tryReadTextFile

lib/utils.ts:637–643  ·  view source on GitHub ↗
(filename: string)

Source from the content-addressed store, hash-verified

635 * Try and read a file as a utf-8 text file, returning its contents if present, or undefined if not.
636 */
637export async function tryReadTextFile(filename: string): Promise<string | undefined> {
638 try {
639 return await fs.readFile(filename, 'utf8');
640 } catch {
641 return undefined;
642 }
643}
644
645/**
646 * Try and read a file as a utf-8 json file, returning its contents if present, or undefined if not.

Callers 1

tryReadJsonFileFunction · 0.85

Calls 1

readFileMethod · 0.80

Tested by

no test coverage detected