Skip to content

Commit 3d0ff8c

Browse files
mshimaSBoudrias
authored andcommitted
Workaround node.js bug that closes main input and output stream. (#879)
* Workaround node.js bug that closes main input and output stream. * Update baseUI.js
1 parent 7ec6ea0 commit 3d0ff8c

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

packages/inquirer/lib/ui/baseUI.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
var _ = require('lodash');
33
var MuteStream = require('mute-stream');
44
var readline = require('readline');
5+
var { PassThrough } = require('stream');
56

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

74+
if (/^win/i.test(process.platform)) {
75+
// @see https://github.com/nodejs/node/issues/21771
76+
// rl.close() closes main stream.
77+
var oldInput = input;
78+
input = new PassThrough();
79+
oldInput.pipe(input);
80+
}
81+
7382
return _.extend(
7483
{
7584
terminal: true,

0 commit comments

Comments
 (0)