Skip to content

Commit

Permalink
close keypress stream when rl close (#835)
Browse files Browse the repository at this point in the history
  • Loading branch information
PG Herveou authored and SBoudrias committed Aug 11, 2019
1 parent 83e8727 commit 7bcb7d3
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/inquirer/lib/utils/events.js
@@ -1,13 +1,14 @@
'use strict';
var { fromEvent } = require('rxjs');
var { filter, map, share } = require('rxjs/operators');
var { filter, map, share, takeUntil } = require('rxjs/operators');

function normalizeKeypressEvents(value, key) {
return { value: value, key: key || {} };
}

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

Expand Down

0 comments on commit 7bcb7d3

Please sign in to comment.