Skip to content

Commit

Permalink
Workaround node.js bug that closes main input and output stream. (#879)
Browse files Browse the repository at this point in the history
* Workaround node.js bug that closes main input and output stream.

* Update baseUI.js
  • Loading branch information
mshima authored and SBoudrias committed Jan 5, 2020
1 parent 7ec6ea0 commit 3d0ff8c
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions packages/inquirer/lib/ui/baseUI.js
Expand Up @@ -2,6 +2,7 @@
var _ = require('lodash');
var MuteStream = require('mute-stream');
var readline = require('readline');
var { PassThrough } = require('stream');

/**
* Base interface class other can inherits from
Expand Down Expand Up @@ -70,6 +71,14 @@ function setupReadlineOptions(opt) {
ms.pipe(opt.output || process.stdout);
var output = ms;

if (/^win/i.test(process.platform)) {
// @see https://github.com/nodejs/node/issues/21771
// rl.close() closes main stream.
var oldInput = input;
input = new PassThrough();
oldInput.pipe(input);
}

return _.extend(
{
terminal: true,
Expand Down

0 comments on commit 3d0ff8c

Please sign in to comment.