Skip to content

Commit 7bcb7d3

Browse files
PG HerveouSBoudrias
authored andcommitted
close keypress stream when rl close (#835)
1 parent 83e8727 commit 7bcb7d3

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

packages/inquirer/lib/utils/events.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
'use strict';
22
var { fromEvent } = require('rxjs');
3-
var { filter, map, share } = require('rxjs/operators');
3+
var { filter, map, share, takeUntil } = require('rxjs/operators');
44

55
function normalizeKeypressEvents(value, key) {
66
return { value: value, key: key || {} };
77
}
88

99
module.exports = function(rl) {
1010
var keypress = fromEvent(rl.input, 'keypress', normalizeKeypressEvents)
11+
.pipe(takeUntil(fromEvent(rl, 'close')))
1112
// Ignore `enter` key. On the readline, we only care about the `line` event.
1213
.pipe(filter(({ key }) => key.name !== 'enter' && key.name !== 'return'));
1314

0 commit comments

Comments
 (0)