diff --git a/index.js b/index.js index 0da3a56..6f78774 100644 --- a/index.js +++ b/index.js @@ -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) } }) diff --git a/test/fixtures/yargs-497-stderr.js b/test/fixtures/yargs-497-stderr.js index 9b498af..1362d61 100755 --- a/test/fixtures/yargs-497-stderr.js +++ b/test/fixtures/yargs-497-stderr.js @@ -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++) { diff --git a/test/fixtures/yargs-497-stdout.js b/test/fixtures/yargs-497-stdout.js index fdc792a..ae29976 100755 --- a/test/fixtures/yargs-497-stdout.js +++ b/test/fixtures/yargs-497-stdout.js @@ -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++) {