Skip to content

Commit

Permalink
feat: add an isTTY check (#3)
Browse files Browse the repository at this point in the history
BREAKING CHANGE: stdio/stderr will not be set to blocking if isTTY === false
  • Loading branch information
Fishrock123 authored and bcoe committed May 17, 2016
1 parent 7d0c45e commit 66ce277
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module.exports = function (blocking) {
[process.stdout, process.stderr].forEach(function (stream) {
if (stream._handle && typeof stream._handle.setBlocking === 'function') {
if (stream._handle && stream.isTTY && typeof stream._handle.setBlocking === 'function') {
stream._handle.setBlocking(blocking)
}
})
Expand Down
4 changes: 4 additions & 0 deletions test/fixtures/yargs-497-stderr.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#!/usr/bin/env node

// pretend we are a TTY
process.stdout.isTTY = true
process.stderr.isTTY = true

// see: https://github.com/yargs/yargs/issues/497
var buffer = ''
for (var i = 0; i < 3000; i++) {
Expand Down
4 changes: 4 additions & 0 deletions test/fixtures/yargs-497-stdout.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#!/usr/bin/env node

// pretend we are a TTY
process.stdout.isTTY = true
process.stderr.isTTY = true

// see: https://github.com/yargs/yargs/issues/497
var buffer = ''
for (var i = 0; i < 3000; i++) {
Expand Down

0 comments on commit 66ce277

Please sign in to comment.