Pipes node Child Process stdout to simple handler which builds chunks using PassThru then callsback on "end". Useful for executing spawn in your testing frameworks then using assertion before continuing tests.
$ npm install passpipe --save
Import or require Passpipe.
import { spawn } from 'child_process';
import * as passpipe from 'passpipe';
const spawn = require('child-process').spawn;
const passpipe = require('passpipe');
Passpipe accepts method which returns a node ChildProcess, the args you want to pass to the process and a callback to be called on [PassThru] end. You can also pass a command as the method that is known to your system in which case Passpipe will create spawn.
const proc = passpipe.method(spawn, /* spawn args */, (chunk) => {
// do something with chunk.
});
Example using Mocha/Chai testing frameworks.
const mocha = require('mocha');
const chai = require('chai');
const passpipe = require('../');
const assert = chai.assert;
it('should spawn and output.', (done) => {
passpipe.command('npm', ['prefix', '-g'], (chunk) => {
assert.equal(chunk, '/usr/local');
done();
});
});
See CHANGE.md
See LICENSE.md