rxcmd
v0.3.0
Published
Execute unix shell process as RxJS Observable like RxCmd.exec('echo hello').subscribe(...)
Downloads
36
Readme
rxcmd
Execute unix shell command process as RxJS Observable like RxCmd.exec('echo hello').subscribe(...)
Install
npm install rxcmdRxCmd=require('rxcmd');Usage
Run unix command (exec)
RxCmd.exec('echo Hello World')
.subscribe(function(output){console.log(output);});
->
Hello WorldFiltering (filter/liftFilter)
RxCmd.exec('echo Hello World').lift(RxCmd.filter('sed s/World/RxCmd/'))
.subscribe(function(output){console.log(output);});
->
Hello RxCmdParallel execution (mapExec/mapFilter)
var commands=[
'echo foo',
'echo bar',
'echo boo'
]
Rx.Observable.from(commands)
.flatMap(RxCmd.mapExec()).flatMap(RxCmd.mapFilter('sed s/o/x/g'))
.subscribe(function(output){console.log(output);});
->
fxx
bar
bxxSink (sink)
Rx.Observable.from('Hello World').subscribe(RxCmd.sink(function(err,stdout){
console.log(stdout); #"Hello World"
}));
Rx.Observable.from('Hello World').subscribe(RxCmd.sink());
-> Hello World (Simply print if no argument)Connecting process.stdin
#test.js
RxCmd.exec('cat',{stdin:true})
.subscribe(function(output){console.log(output);});
>echo Hello|node test.js
-> HelloChange Log
- 0.3.x:using spawn() instead of exec()
- 0.3.x:breaking changes:filter()=liftFilter() specification
- 0.3.x:breaking changes:sink() specification
- 0.3.x:breaking changes:filter()->mapFilter()/multiExec()->mapExec()
- 0.2.x:added sink()
- 0.1.x:first release
