(command, args, folder)
| 35 | }); |
| 36 | |
| 37 | async function run(command, args, folder) { |
| 38 | const child = spawn(command, args, { |
| 39 | cwd: folder, |
| 40 | stdio: 'pipe', |
| 41 | env: process.env, |
| 42 | shell: true, |
| 43 | // On non-windows platforms, `detached: true` makes child process a leader of a new |
| 44 | // process group, making it possible to kill child process tree with `.kill(-pid)` command. |
| 45 | // @see https://nodejs.org/api/child_process.html#child_process_options_detached |
| 46 | detached: !isWindows, |
| 47 | }); |
| 48 | activeChild = child; |
| 49 | child.stdout.on('data', data => process.stdout.write(data)); |
| 50 | child.stderr.on('data', data => process.stdout.write(data)); |
| 51 | process.on('exit', onExit); |
| 52 | const code = await new Promise(f => child.on('close', f)); |
| 53 | expect(code).toEqual(0); |
| 54 | } |
| 55 | |
| 56 | function onExit() { |
| 57 | if (activeChild) { |
no test coverage detected