pax_global_header 0000666 0000000 0000000 00000000064 12716721026 0014516 g ustar 00root root 0000000 0000000 52 comment=7eec10577b5fff264de477ba3b9d07f404946eff
set-blocking-2.0.0/ 0000775 0000000 0000000 00000000000 12716721026 0014076 5 ustar 00root root 0000000 0000000 set-blocking-2.0.0/.gitignore 0000664 0000000 0000000 00000000054 12716721026 0016065 0 ustar 00root root 0000000 0000000 node_modules
.DS_Store
.nyc_output
coverage
set-blocking-2.0.0/.travis.yml 0000664 0000000 0000000 00000000205 12716721026 0016204 0 ustar 00root root 0000000 0000000 language: node_js
os:
- linux
- osx
after_success: npm run coverage
node_js:
- "0.10"
- "0.12"
- "4"
- "5"
- "node"
set-blocking-2.0.0/CHANGELOG.md 0000664 0000000 0000000 00000001316 12716721026 0015710 0 ustar 00root root 0000000 0000000 # Change Log
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
# [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
# 1.0.0 (2016-05-14)
### Features
* implemented shim for stream._handle.setBlocking ([6bde0c0](https://github.com/yargs/set-blocking/commit/6bde0c0))
set-blocking-2.0.0/LICENSE.txt 0000664 0000000 0000000 00000001333 12716721026 0015721 0 ustar 00root root 0000000 0000000 Copyright (c) 2016, Contributors
Permission to use, copy, modify, and/or distribute this software
for any purpose with or without fee is hereby granted, provided
that the above copyright notice and this permission notice
appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE
LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES
OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
set-blocking-2.0.0/README.md 0000664 0000000 0000000 00000003002 12716721026 0015350 0 ustar 00root root 0000000 0000000 # set-blocking
[](https://travis-ci.org/yargs/set-blocking)
[](https://www.npmjs.com/package/set-blocking)
[](https://coveralls.io/r/yargs/set-blocking?branch=master)
[](https://github.com/conventional-changelog/standard-version)
set blocking `stdio` and `stderr` ensuring that terminal output does not truncate.
```js
const setBlocking = require('set-blocking')
setBlocking(true)
console.log(someLargeStringToOutput)
```
## 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
set-blocking-2.0.0/index.js 0000664 0000000 0000000 00000000374 12716721026 0015547 0 ustar 00root root 0000000 0000000 module.exports = function (blocking) {
[process.stdout, process.stderr].forEach(function (stream) {
if (stream._handle && stream.isTTY && typeof stream._handle.setBlocking === 'function') {
stream._handle.setBlocking(blocking)
}
})
}
set-blocking-2.0.0/package.json 0000664 0000000 0000000 00000001731 12716721026 0016366 0 ustar 00root root 0000000 0000000 {
"name": "set-blocking",
"version": "2.0.0",
"description": "set blocking stdio and stderr ensuring that terminal output does not truncate",
"main": "index.js",
"scripts": {
"pretest": "standard",
"test": "nyc mocha ./test/*.js",
"coverage": "nyc report --reporter=text-lcov | coveralls",
"version": "standard-version"
},
"repository": {
"type": "git",
"url": "git+https://github.com/yargs/set-blocking.git"
},
"keywords": [
"flush",
"terminal",
"blocking",
"shim",
"stdio",
"stderr"
],
"author": "Ben Coe ",
"license": "ISC",
"bugs": {
"url": "https://github.com/yargs/set-blocking/issues"
},
"homepage": "https://github.com/yargs/set-blocking#readme",
"devDependencies": {
"chai": "^3.5.0",
"coveralls": "^2.11.9",
"mocha": "^2.4.5",
"nyc": "^6.4.4",
"standard": "^7.0.1",
"standard-version": "^2.2.1"
},
"files": [
"index.js",
"LICENSE.txt"
]
} set-blocking-2.0.0/test/ 0000775 0000000 0000000 00000000000 12716721026 0015055 5 ustar 00root root 0000000 0000000 set-blocking-2.0.0/test/fixtures/ 0000775 0000000 0000000 00000000000 12716721026 0016726 5 ustar 00root root 0000000 0000000 set-blocking-2.0.0/test/fixtures/yargs-497-stderr.js 0000775 0000000 0000000 00000000553 12716721026 0022241 0 ustar 00root root 0000000 0000000 #!/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++) {
buffer += 'line ' + i + '\n'
}
var setBlocking = require('../../')
setBlocking(true)
console.error(buffer)
process.exit(1)
console.log('should not execute')
set-blocking-2.0.0/test/fixtures/yargs-497-stdout.js 0000775 0000000 0000000 00000000551 12716721026 0022256 0 ustar 00root root 0000000 0000000 #!/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++) {
buffer += 'line ' + i + '\n'
}
var setBlocking = require('../../')
setBlocking(true)
console.log(buffer)
process.exit(0)
console.log('should not execute')
set-blocking-2.0.0/test/test.js 0000664 0000000 0000000 00000001370 12716721026 0016373 0 ustar 00root root 0000000 0000000 /* global describe, it */
var exec = require('child_process').exec
require('chai').should()
describe('setBlocking', function () {
// see: https://github.com/yargs/yargs/issues/497
it('does not truncate text printed to stdout when process.exit() is called', function (done) {
exec('./test/fixtures/yargs-497-stdout.js', function (err, stdout, stderr) {
if (err) return done(err)
stdout.should.match(/line 2999/)
return done()
})
})
it('does not truncate text printed to stderr when process.exit() is called', function (done) {
exec('./test/fixtures/yargs-497-stderr.js', function (err, stdout, stderr) {
err.should.match(/Command failed/)
stderr.should.match(/line 2999/)
return done()
})
})
})