({
registerHooks,
createReplOpts,
createServiceOpts,
}: CreateReplViaApiOptions)
| 31 | return { createReplViaApi, executeInRepl }; |
| 32 | |
| 33 | function createReplViaApi({ |
| 34 | registerHooks, |
| 35 | createReplOpts, |
| 36 | createServiceOpts, |
| 37 | }: CreateReplViaApiOptions) { |
| 38 | const stdin = new PassThrough(); |
| 39 | const stdout = new PassThrough(); |
| 40 | const stderr = new PassThrough(); |
| 41 | const replService = tsNodeUnderTest.createRepl({ |
| 42 | stdin, |
| 43 | stdout, |
| 44 | stderr, |
| 45 | ...createReplOpts, |
| 46 | }); |
| 47 | const service = ( |
| 48 | registerHooks ? tsNodeUnderTest.register : tsNodeUnderTest.create |
| 49 | )({ |
| 50 | ...replService.evalAwarePartialHost, |
| 51 | project: `${TEST_DIR}/tsconfig.json`, |
| 52 | ...createServiceOpts, |
| 53 | tsTrace: replService.console.log.bind(replService.console), |
| 54 | }); |
| 55 | replService.setService(service); |
| 56 | t.teardown(async () => { |
| 57 | service.enabled(false); |
| 58 | }); |
| 59 | |
| 60 | return { stdin, stdout, stderr, replService, service }; |
| 61 | } |
| 62 | |
| 63 | async function executeInRepl(input: string, options: ExecuteInReplOptions) { |
| 64 | const { |
no test coverage detected
searching dependent graphs…