Name Last Update
..
test Loading commit data...
.editorconfig Loading commit data...
.eslintrc.json Loading commit data...
.gitattributes Loading commit data...
.travis.yml Loading commit data...
LICENSE Loading commit data...
README.md Loading commit data...
index.js Loading commit data...
package.json Loading commit data...

spawn-please

npm version

Promisified child_process.spawn. *Supports stdin* *Rejects on stderr*

Install

$ npm install --save spawn-please

Usage

await spawn(command, [arguments], [stdin], [options])

options are passed directly to child_process.spawn.

const spawn = require('spawn-please')

const output = await spawn('printf', ['please?'])
assert.equal(output, 'please?')

How is this different than other child_process libraries?

  • Allows you to pass a string to stdin:
const output = await spawn('cat', [], 'test')
assert.equal(output, 'test')

  • Rejects on any stderr:
try {
  spawn('some-command-with-stderr')
}
catch (stderr) {
  // do something with stderr
}

Using your own Promise library

spawn-please uses the global Promise object by default. You may use your own Promise library by overriding the Promise property:

const spawn = require('spawn-please')
spawn.Promise = require('bluebird')

License

ISC © Raine Revere