lib/pipeStream.js
function createPipeStream(cmd/*, args, opts*/){
    var proc;
    var command;

    if(Array.isArray(cmd)){
    // We have an array so create a pipe from all elements
    var firstCmd = cmd.shift();
    var open = Array.isArray(firstCmd) ? createPipeStream.apply({}, firstCmd) : createPipeStream(firstCmd);
    cmd.forEach(function(p){
        open = open.pipe(p);
    });
    return open;

    } else if(cmd instanceof EventEmitter){
        // Take the eventemitter as base
        proc = cmd;
        command = 'pre-defined';

    } else if(typeof cmd === 'object'){
        throw new TypeError('Invalid input, expected object type -> EventEmitter');

    } else {
        // We have input for Spawn command, normalize the input and create spawn
        var input = utils.normalizeInput.apply(this, arguments);
        command = utils.getCommand(input);
        proc = spawn.apply({}, input);
    }

    // Create inner pointer for command
    proc._command = command;

    // Check if process is still alive
    if(proc.exitCode){
        throw new Error('Process already dead');
    }

    return PipeStream(proc);
}
function createPipeStream(cmd/*, args, opts*/){
    var proc;
    var command;

    if(Array.isArray(cmd)){
    // We have an array so create a pipe from all elements
    var firstCmd = cmd.shift();
    var open = Array.isArray(firstCmd) ? createPipeStream.apply({}, firstCmd) : createPipeStream(firstCmd);
    cmd.forEach(function(p){
        open = open.pipe(p);
    });
    return open;

    } else if(cmd instanceof EventEmitter){
        // Take the eventemitter as base
        proc = cmd;
        command = 'pre-defined';

    } else if(typeof cmd === 'object'){
        throw new TypeError('Invalid input, expected object type -> EventEmitter');

    } else {
        // We have input for Spawn command, normalize the input and create spawn
        var input = utils.normalizeInput.apply(this, arguments);
        command = utils.getCommand(input);
        proc = spawn.apply({}, input);
    }

    // Create inner pointer for command
    proc._command = command;

    // Check if process is still alive
    if(proc.exitCode){
        throw new Error('Process already dead');
    }

    return PipeStream(proc);
}
Main entrance function, will create PipeStream or joined pipe based on input

@param {Object|String|Array} cmd a Stream or Spawn object
or string command to create a spawn object
or an array of the previous types
@param {Array} [args=[]] optional array to string command
@param {Object} [opts={}] optional options to string command
@returns {PipeStream}