Skip to content

Commit

Permalink
fix(core): restart app in development via CLI multiple times (#904)
Browse files Browse the repository at this point in the history
Fixes #903.
  • Loading branch information
Miaow authored and malept committed Jun 12, 2019
1 parent a91d8b3 commit df98fe8
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions packages/api/core/src/api/start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,20 +113,22 @@ export default async ({
};

const forgeSpawnWrapper = async () => {
lastSpawned = await forgeSpawn();
const spawned = await forgeSpawn();
// When the child app is closed we should stop listening for stdin
if (lastSpawned) {
if (spawned) {
if (interactive && process.stdin.isPaused()) {
process.stdin.resume();
}
lastSpawned.on('exit', () => {
if ((lastSpawned as any).restarted) return;
spawned.on('exit', () => {
if ((spawned as any).restarted) return;

if (!process.stdin.isPaused()) process.stdin.pause();
});
} else if (interactive && !process.stdin.isPaused()) {
process.stdin.pause();
}

lastSpawned = spawned;
return lastSpawned;
};

Expand Down

0 comments on commit df98fe8

Please sign in to comment.