@ahmadnassri/spawn-promise

Child Process Spawn as a Promise, with simple in/out piping

Usage no npm install needed!

<script type="module">
  import ahmadnassriSpawnPromise from 'https://cdn.skypack.dev/@ahmadnassri/spawn-promise';
</script>

README

Spawn Promise version License Build Status Downloads Coverage Status

Child Process Spawn as a Promise, with simple in/out piping

Install

npm install --production --save @ahmadnassri/spawn-promise

API

spawn (command [, args] [, options] [, input])

identical to child_process.spawn in every way, except:

  • writes the input value to stdin,
  • on success returns a Promise that is fulfilled with a simple object containing both stdout & stderr buffers.
  • on failure returns a Promise rejected with a SpawnError error object containing both stdout & stderr buffers.

Usage

const spawn = require('@ahmadnassri/spawn-promise')

const options = {
  env: process.env
}

// success
spawn('grep', ['f'], options, 'foo')
  .then(streams => console.log(streams.stdout))

License: ISC  ·  Copyright: ahmadnassri.com  ·  Github: @ahmadnassri  ·  Twitter: @ahmadnassri