greduan / node-unix-pipe

Simulate a Unix process pipeline with pure Node.js

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

unix-pipe

Execute with Node.js a list of defined processes and pipe the outputs of each one to the next one in the definition.

Returns a Transform Stream to which you pipe in the input you want to pass through the processes pipeline and which pipes out the output of the pipeline.

Current problem I'm solving

If you check the code you'll notice this is still in an unfinished state.

Sadly I've come across a roadblock on what I can do about this. If you've an idea on how to solve this please do open an issue or PR about this 😄

The part of the process I haven't figured out is marked by an X Mermaid flowchart

The reason that's hard to figure out is because the input to the transform stream is a block, but the input the transform's gotta pass to the pipeline is a stream not a block. Look at the code and you'll see what I mean.

If you are actually interested in helping me out with this one let me know so I can provide all the info you need, in case you are able to solve it 😃

Installation

$ git clone https://github.com/greduan/node-unix-pipe.git
$ cd node-unix-pipe
$ npm i
$ npm link

Usage

CoffeeScript pipe example

// Make a pipe that just formats the input through CS

var pipe = require('unix-pipe');

var coffee = pipe([
  {
    command: 'coffee',
    options: ['-s', '-p'],
  },
]);

// Pipe file through the CoffeeScript pipeline

var fs = require('fs');

var srcFile = fs.createReadStream('/some/path.cs');
var outFile = fs.createWriteStream('/some/path.js');

// srcFile -> coffee -> outFile
srcFile.pipe(coffee).pipe(outFile);

Process definition format

[
  {
    command: String, // Unix command name
    options: Array, // options and other to pass to the command
  },
]

License

Licensed under the permissive ISC license. Check the LICENSE file for further details.

About

Simulate a Unix process pipeline with pure Node.js

License:ISC License


Languages

Language:JavaScript 100.0%