Skip to content

Commit 499679f

Browse files
authored
fix: resume stdin when setting up dev server interactions (#1525)
1 parent a09c630 commit 499679f

2 files changed

Lines changed: 16 additions & 0 deletions

File tree

‎packages/repack/src/commands/common/__tests__/setupInteractions.test.ts‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ describe('setupInteractions', () => {
3030
},
3131
stdin: {
3232
setRawMode: jest.fn(),
33+
resume: jest.fn(),
3334
on: jest.fn(),
3435
},
3536
stdout: {
@@ -85,6 +86,19 @@ describe('setupInteractions', () => {
8586
);
8687
});
8788

89+
it('should resume stdin so keypresses are delivered after it was paused', () => {
90+
setupInteractions(
91+
{},
92+
{
93+
logger: mockLogger,
94+
process: mockProcess,
95+
readline: mockReadline,
96+
}
97+
);
98+
99+
expect(mockProcess.stdin.resume).toHaveBeenCalledTimes(1);
100+
});
101+
88102
it('should handle ctrl+c and ctrl+z keypresses', () => {
89103
setupInteractions(
90104
{},

‎packages/repack/src/commands/common/setupInteractions.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ export function setupInteractions(
4040

4141
readline.emitKeypressEvents(process.stdin);
4242
process.stdin.setRawMode(true);
43+
// Raw mode makes Ctrl+C arrive only as stream data, so a paused stream would swallow it.
44+
process.stdin.resume();
4345

4446
// graceful shutdown
4547
process.on('SIGINT', () => {

0 commit comments

Comments
 (0)