Skip to content

Commit 66ce277

Browse files
Fishrock123bcoe
authored andcommitted
feat: add an isTTY check (#3)
BREAKING CHANGE: stdio/stderr will not be set to blocking if isTTY === false
1 parent 7d0c45e commit 66ce277

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module.exports = function (blocking) {
22
[process.stdout, process.stderr].forEach(function (stream) {
3-
if (stream._handle && typeof stream._handle.setBlocking === 'function') {
3+
if (stream._handle && stream.isTTY && typeof stream._handle.setBlocking === 'function') {
44
stream._handle.setBlocking(blocking)
55
}
66
})

test/fixtures/yargs-497-stderr.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
#!/usr/bin/env node
22

3+
// pretend we are a TTY
4+
process.stdout.isTTY = true
5+
process.stderr.isTTY = true
6+
37
// see: https://github.com/yargs/yargs/issues/497
48
var buffer = ''
59
for (var i = 0; i < 3000; i++) {

test/fixtures/yargs-497-stdout.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
#!/usr/bin/env node
22

3+
// pretend we are a TTY
4+
process.stdout.isTTY = true
5+
process.stderr.isTTY = true
6+
37
// see: https://github.com/yargs/yargs/issues/497
48
var buffer = ''
59
for (var i = 0; i < 3000; i++) {

0 commit comments

Comments
 (0)