Skip to content

Commit

Permalink
fix(core): stop specs hanging due to pending process.stdin listener
Browse files Browse the repository at this point in the history
  • Loading branch information
MarshallOfSound committed May 14, 2018
1 parent 987161e commit b747c99
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
18 changes: 10 additions & 8 deletions packages/api/core/src/api/start.ts
Expand Up @@ -106,14 +106,16 @@ export default async ({
return spawned;
};

process.stdin.on('data', (data) => {
if (data.toString().trim() === 'rs' && lastSpawned) {
console.info('\nRestarting App\n'.cyan);
(lastSpawned as any).restarted = true;
lastSpawned.kill('SIGTERM');
forgeSpawnWrapper();
}
});
if (interactive) {
process.stdin.on('data', (data) => {
if (data.toString().trim() === 'rs' && lastSpawned) {
console.info('\nRestarting App\n'.cyan);
(lastSpawned as any).restarted = true;
lastSpawned.kill('SIGTERM');
forgeSpawnWrapper();
}
});
}

return forgeSpawnWrapper();
};
6 changes: 6 additions & 0 deletions packages/api/core/test/fast/start_spec.ts
Expand Up @@ -12,6 +12,7 @@ describe('start', () => {
let resolveStub: SinonStub;
let spawnStub: SinonStub;
let shouldOverride: boolean;
let processOn: SinonStub;

beforeEach(() => {
resolveStub = sinon.stub();
Expand All @@ -34,6 +35,11 @@ describe('start', () => {
spawn: spawnStub,
},
}).default;
processOn = sinon.stub(process.stdin, 'on');
});

afterEach(() => {
processOn.restore();
});

it('should spawn electron in the correct dir', async () => {
Expand Down

0 comments on commit b747c99

Please sign in to comment.