* Evaluate an [eval] or [stdin] script
( replService: ReplService, module: Module, code: string, isPrinted: boolean, filenameAndDirname: 'eval' | 'stdin' )
| 767 | * Evaluate an [eval] or [stdin] script |
| 768 | */ |
| 769 | function evalAndExitOnTsError( |
| 770 | replService: ReplService, |
| 771 | module: Module, |
| 772 | code: string, |
| 773 | isPrinted: boolean, |
| 774 | filenameAndDirname: 'eval' | 'stdin' |
| 775 | ) { |
| 776 | let result: any; |
| 777 | setupContext(global, module, filenameAndDirname); |
| 778 | |
| 779 | try { |
| 780 | result = replService.evalCode(code); |
| 781 | } catch (error) { |
| 782 | if (error instanceof TSError) { |
| 783 | console.error(error); |
| 784 | process.exit(1); |
| 785 | } |
| 786 | |
| 787 | throw error; |
| 788 | } |
| 789 | |
| 790 | if (isPrinted) { |
| 791 | console.log( |
| 792 | typeof result === 'string' |
| 793 | ? result |
| 794 | : inspect(result, { colors: process.stdout.isTTY }) |
| 795 | ); |
| 796 | } |
| 797 | } |
| 798 | |
| 799 | if (require.main === module) { |
| 800 | main(); |
no test coverage detected
searching dependent graphs…