rxrunscript

Run shell script in child process, Output Observable<Buffer>


Keywords
npm run, run-script, rxjs, script, spawn
License
MIT
Install
npm install rxrunscript@6.2.0

Documentation

RxRunScript

Run shell script or command in Node.js child process, Output Observable<Buffer>

Version License Build Status Build status Coverage Status

Installing

$ npm install rxrunscript

Usage

import { run } from 'rxrunscript'
import { take } from 'rxjs/operators'

run('openssl version')
  .pipe(
    take(1),  // assume all output in one buffer
  )
  .subscribe(
    buf => console.log(buf.toString()), 
    err => console.error(err),
  ) 

// exec shell file
run('./test/openssl.sh')
  .subscribe(
    arr => console.log(buf.toString()),
  )


import { reduce } from 'rxjs/operators'

// win32
run('tasklist')
  .pipe(
    reduce((acc: Buffer[], curr: Buffer) => {
      acc.push(curr)
      return acc
    }, []),
  )
  .subscribe(
    arr => console.log(Buffer.concat(arr).toString()),
    err => console.error(err),
    () => console.log('complete'),
  )

// run cmd file
run('./test/prepare.cmd')
  .subscribe(
    arr => console.log(buf.toString()),
  )

License

MIT

Languages