MCPcopy Create free account
hub / github.com/TestSprite/testsprite-cli / readCodeFile

Function readCodeFile

src/commands/test.ts:880–894  ·  view source on GitHub ↗
(path: string)

Source from the content-addressed store, hash-verified

878}
879
880function readCodeFile(path: string): string {
881 try {
882 return readFileSync(resolveAbsolute(path), 'utf8');
883 } catch (err) {
884 const code = (err as NodeJS.ErrnoException).code;
885 if (code === 'ENOENT') {
886 throw localValidationError('code-file', `file does not exist: ${path}`);
887 }
888 if (code === 'EACCES') {
889 throw localValidationError('code-file', `permission denied reading ${path}`);
890 }
891 const reason = err instanceof Error ? err.message : 'unknown error';
892 throw localValidationError('code-file', `cannot read ${path}: ${reason}`);
893 }
894}
895
896function resolveAbsolute(path: string): string {
897 return isAbsolute(path) ? path : resolve(process.cwd(), path);

Callers 1

readCodeFileGuardedFunction · 0.85

Calls 3

readFileSyncFunction · 0.85
resolveAbsoluteFunction · 0.85
localValidationErrorFunction · 0.70

Tested by

no test coverage detected