Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

stdio-capture

alancnet114MIT1.0.0

Captures stdout and stderr events.

readme

stdio-capture

Captures stdout and stderr events.

Does not capture console.log or console.error called within event handler.

Usage

const capture = require('stdio-capture')

const capture = require('.')

capture.on('stdout', text => {
  console.log(`I just captured "${text}" from stdout!`)
  console.log('But this text will not be captured.')
})

capture.on('stderr', text => {
  console.log(`I just captured "${text}" from stderr!`)
  console.log('But this text will not be captured.')
})

capture.enable()

console.log('This text')
console.error('Also this text')

capture.disable()

console.log('But not this text')
console.error('Or this text')