$ cnpm install spawn-please
Promisified child_process.spawn. *Supports stdin* *Rejects on stderr*
$ npm install --save spawn-please
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?')
const output = await spawn('cat', [], 'test')
assert.equal(output, 'test')
try {
spawn('some-command-with-stderr')
}
catch (stderr) {
// do something with stderr
}
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')
ISC © Raine Revere
Copyright 2013 - present © cnpmjs.org | Home |