Skip to content

origin1tech/passpipe

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Passpipe

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.

Install

$ npm install passpipe --save

Import

Import or require Passpipe.

TypeScript

import { spawn } from 'child_process';
import * as passpipe from 'passpipe';

Require

const spawn = require('child-process').spawn;
const passpipe = require('passpipe');

Usage

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

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();
  });
});

Change

See CHANGE.md

License

See LICENSE.md

About

Module for piping stream to pass through useful for testing frameworks.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published