| 262 | }; |
| 263 | |
| 264 | const forgeSpawnWrapper = async () => { |
| 265 | const spawned = await forgeSpawn(); |
| 266 | // When the child app is closed we should stop listening for stdin |
| 267 | if (spawned) { |
| 268 | if (interactive && process.stdin.isPaused()) { |
| 269 | process.stdin.resume(); |
| 270 | } |
| 271 | spawned.on('exit', () => { |
| 272 | if (spawned.restarted) { |
| 273 | return; |
| 274 | } |
| 275 | |
| 276 | if (interactive && !process.stdin.isPaused()) { |
| 277 | process.stdin.pause(); |
| 278 | } |
| 279 | }); |
| 280 | } else if (interactive && !process.stdin.isPaused()) { |
| 281 | process.stdin.pause(); |
| 282 | } |
| 283 | |
| 284 | lastSpawned = spawned; |
| 285 | return lastSpawned; |
| 286 | }; |
| 287 | |
| 288 | if (interactive) { |
| 289 | process.stdin.on('data', (data) => { |