( state: EvalState, composeWith?: EvalAwarePartialHost )
| 465 | >; |
| 466 | |
| 467 | export 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 | |
| 497 | const sourcemapCommentRe = /\/\/# ?sourceMappingURL=\S+[\s\r\n]*$/; |
| 498 |
no outgoing calls
no test coverage detected
searching dependent graphs…