MCPcopy Index your code
hub / github.com/TypeStrong/ts-node / createEvalAwarePartialHost

Function createEvalAwarePartialHost

src/repl.ts:467–495  ·  view source on GitHub ↗
(
  state: EvalState,
  composeWith?: EvalAwarePartialHost
)

Source from the content-addressed store, hash-verified

465>;
466
467export function createEvalAwarePartialHost(
468 state: EvalState,
469 composeWith?: EvalAwarePartialHost
470): EvalAwarePartialHost {
471 function readFile(path: string) {
472 if (path === state.path) return state.input;
473
474 if (composeWith?.readFile) return composeWith.readFile(path);
475
476 try {
477 return readFileSync(path, 'utf8');
478 } catch (err) {
479 /* Ignore. */
480 }
481 }
482 function fileExists(path: string) {
483 if (path === state.path) return true;
484
485 if (composeWith?.fileExists) return composeWith.fileExists(path);
486
487 try {
488 const stats = statSync(path);
489 return stats.isFile() || stats.isFIFO();
490 } catch (err) {
491 return false;
492 }
493 }
494 return { readFile, fileExists };
495}
496
497const sourcemapCommentRe = /\/\/# ?sourceMappingURL=\S+[\s\r\n]*$/;
498

Callers 1

createReplFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…