Skip to content

Commit f1d3982

Browse files
committed
Fix holding open process.stdin indefinitely in test environments
1 parent 969f538 commit f1d3982

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/index.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ module.exports = {
3232
events.cancel = ''
3333

3434
process.stdin.on('data', async function eventInvokeListener (input) {
35+
start()
3536
input = String(input)
3637
// Reset Enquirer's styles
3738
let options = {
@@ -111,10 +112,15 @@ module.exports = {
111112
}
112113

113114
// Necessary per Enquirer #326
114-
function end () {
115+
function start () {
115116
if (process.stdin.isTTY) {
116117
process.stdin.setRawMode(true)
117118
process.stdin.setEncoding('utf8')
118119
process.stdin.resume()
119120
}
120121
}
122+
function end () {
123+
if (process.stdin.isTTY) {
124+
process.stdin.pause()
125+
}
126+
}

0 commit comments

Comments
 (0)