You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
1.5 KiB

4 years ago
  1. # set-blocking
  2. [![Build Status](https://travis-ci.org/yargs/set-blocking.svg)](https://travis-ci.org/yargs/set-blocking)
  3. [![NPM version](https://img.shields.io/npm/v/set-blocking.svg)](https://www.npmjs.com/package/set-blocking)
  4. [![Coverage Status](https://coveralls.io/repos/yargs/set-blocking/badge.svg?branch=)](https://coveralls.io/r/yargs/set-blocking?branch=master)
  5. [![Standard Version](https://img.shields.io/badge/release-standard%20version-brightgreen.svg)](https://github.com/conventional-changelog/standard-version)
  6. set blocking `stdio` and `stderr` ensuring that terminal output does not truncate.
  7. ```js
  8. const setBlocking = require('set-blocking')
  9. setBlocking(true)
  10. console.log(someLargeStringToOutput)
  11. ```
  12. ## Historical Context/Word of Warning
  13. 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
  14. newer versions of Node.js (`0.12+`), truncating terminal output.
  15. You should be mindful of the side-effects caused by using `set-blocking`:
  16. * if your module sets blocking to `true`, it will effect other modules
  17. consuming your library. In [yargs](https://github.com/yargs/yargs/blob/master/yargs.js#L653) we only call
  18. `setBlocking(true)` once we already know we are about to call `process.exit(code)`.
  19. * this patch will not apply to subprocesses spawned with `isTTY = true`, this is
  20. the [default `spawn()` behavior](https://nodejs.org/api/child_process.html#child_process_child_process_spawn_command_args_options).
  21. ## License
  22. ISC