set-blocking
Advanced tools
Comparing version
@@ -5,2 +5,17 @@ # Change Log | ||
<a name="2.0.0"></a> | ||
# [2.0.0](https://github.com/yargs/set-blocking/compare/v1.0.0...v2.0.0) (2016-05-17) | ||
### Features | ||
* add an isTTY check ([#3](https://github.com/yargs/set-blocking/issues/3)) ([66ce277](https://github.com/yargs/set-blocking/commit/66ce277)) | ||
### BREAKING CHANGES | ||
* stdio/stderr will not be set to blocking if isTTY === false | ||
<a name="1.0.0"></a> | ||
@@ -7,0 +22,0 @@ # 1.0.0 (2016-05-14) |
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) | ||
@@ -5,0 +5,0 @@ } |
{ | ||
"name": "set-blocking", | ||
"version": "1.0.0", | ||
"version": "2.0.0", | ||
"description": "set blocking stdio and stderr ensuring that terminal output does not truncate", | ||
@@ -9,3 +9,4 @@ "main": "index.js", | ||
"test": "nyc mocha ./test/*.js", | ||
"coverage": "nyc report --reporter=text-lcov | coveralls" | ||
"coverage": "nyc report --reporter=text-lcov | coveralls", | ||
"version": "standard-version" | ||
}, | ||
@@ -42,2 +43,2 @@ "repository": { | ||
] | ||
} | ||
} |
@@ -16,4 +16,17 @@ # set-blocking | ||
## Historical Context/Word of Warning | ||
This was created as a shim to address the bug discussed in [node #6456](https://github.com/nodejs/node/issues/6456). This bug crops up on | ||
newer versions of Node.js (`0.12+`), truncating terminal output. | ||
You should be mindful of the side-effects caused by using `set-blocking`: | ||
* if your module sets blocking to `true`, it will effect other modules | ||
consuming your library. In [yargs](https://github.com/yargs/yargs/blob/master/yargs.js#L653) we only call | ||
`setBlocking(true)` once we already know we are about to call `process.exit(code)`. | ||
* this patch will not apply to subprocesses spawned with `isTTY = true`, this is | ||
the [default `spawn()` behavior](https://nodejs.org/api/child_process.html#child_process_child_process_spawn_command_args_options). | ||
## License | ||
ISC |
4224
39.82%32
68.42%