Skip to content

Commit 9021612

Browse files
authored
fix: add off for process.stdin keypress (#2156)
1 parent bb1d47a commit 9021612

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

packages/slidev/node/cli.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ cli.command(
281281
if (process.stdin.isTTY)
282282
process.stdin.setRawMode(true)
283283

284-
process.stdin.on('keypress', (str, key) => {
284+
const onKeyPress = (str: string, key: { ctrl: boolean, name: string }) => {
285285
if (key.ctrl && key.name === 'c') {
286286
process.exit()
287287
}
@@ -296,6 +296,11 @@ cli.command(
296296
}
297297
}
298298
}
299+
}
300+
301+
process.stdin.on('keypress', onKeyPress)
302+
server?.httpServer?.on('close', () => {
303+
process.stdin.off('keypress', onKeyPress)
299304
})
300305
}
301306

0 commit comments

Comments
 (0)