1.0.2 • Published 7 years ago

cp-pipe v1.0.2

Weekly downloads
9
License
CC0-1.0
Repository
github
Last release
7 years ago

cp-pipe

Pipe stdout and stderr from child processes without typing as much code.

install

npm install cp-pipe

example

Require the module and make some processes:

const cpPipe = require('cp-pipe')

const a = spawnA()
const b = spawnB()
const c = spawnC()
cpPipe.chainToProcess([a, b, c])

// vs

a.stdout.pipe(b.stdin)
b.stdout.pipe(c.stdin)
c.stdout.pipe(process.stdout)

a.stderr.pipe(process.stderr)
b.stderr.pipe(process.stderr)
c.stderr.pipe(process.stderr)
cpPipe.outIn([a, b, c])

// vs

a.stdout.pipe(b.stdin)
b.stdout.pipe(c.stdin)
cpPipe.err([a, b, c], process)

a.stderr.pipe(process.stderr)
b.stderr.pipe(process.stderr)
c.stderr.pipe(process.stderr)

API

cpPipe.chainToProcess(processes)

  • processes: [] Array of child processes

Pipes the stdout of a prior process from processes into the stdout of the next process, chaining the stdouts/stdins together, pipes the stdout of the last process to process.stdout, and pipes the stderrs of all processes to process.stderr.

cpPipe.outIn(processes)

  • processes: [] Array of child processes

Pipes the stdout of a prior process from processes into the stdout of the next process, chaining the stdouts/stdins together.

cpPipe.err(processes, destProcess)

Pipes the stderrs of all processes to destProcess.stderr.