({
args,
expectedCompletionLog = 'Completed running',
options = {},
})
| 20 | } |
| 21 | |
| 22 | async function runNode({ |
| 23 | args, |
| 24 | expectedCompletionLog = 'Completed running', |
| 25 | options = {}, |
| 26 | }) { |
| 27 | const child = spawn(execPath, args, { encoding: 'utf8', stdio: 'pipe', ...options }); |
| 28 | let stderr = ''; |
| 29 | const stdout = []; |
| 30 | |
| 31 | child.stderr.on('data', (data) => { |
| 32 | stderr += data; |
| 33 | }); |
| 34 | |
| 35 | try { |
| 36 | // Break the chunks into lines |
| 37 | for await (const data of createInterface({ input: child.stdout })) { |
| 38 | if (!data.startsWith('Waiting for graceful termination') && !data.startsWith('Gracefully restarted')) { |
| 39 | stdout.push(data); |
| 40 | } |
| 41 | if (data.startsWith(expectedCompletionLog)) { |
| 42 | break; |
| 43 | } |
| 44 | } |
| 45 | } finally { |
| 46 | child.kill(); |
| 47 | } |
| 48 | return { stdout, stderr, pid: child.pid }; |
| 49 | } |
| 50 | |
| 51 | tmpdir.refresh(); |
| 52 |
no test coverage detected
searching dependent graphs…