promise-spawner
Lazy nodejs spawner with stdout/stderr streams and error handling through promises
Examples
Basic command example
var spawner = spawner
Basic failing command example
var spawner = spawner
Modifiers and streaming
var modifiers = { return d } err: 'this is an error: ' var spawner = modifiers //spawner gives you global streams from spawned stdout and stderrspawneroutspawnererr spawner //this will print "hello\n world\n err\n done\n" to the stdout
Add options on the fly
var previous = var s = spawner s
Every data streamed from the spawn running script is pushed in an array that is accessible through data
. This object contains two arrays : {err: Array, out: Array}
. It is intendend to check stdout/stderr
results when the script has run.
To get better control, use streams!
API
options
: modifiers:{out: Function|String, err: Function|String}
spawn_options
(optional): http://nodejs.org/api/child_process.html- returns an object:
spawn
: spawn a commandsp
: shortcut to spawnout
: global out streamerr
: global err stream
spawner or spawner
command
can be an Array or a Stringspawn_options
(optional): http://nodejs.org/api/child_process.html
Take a look at the https://github.com/soyuka/promise-spawner/blob/master/test/index.js
Licence
The MIT License (MIT)
Copyright (c) 2014 soyuka
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.