I have a bluebird promise, which runs a check. If this check is true, it can continue on. However, if this check is false, it needs to spawn an asynchronous process, which it must wait to complete before continuing.
I have something like the following:
var foo = getPromise();
foo.spread( function (error, stdout, stdin) {
if (error) {
// ok, foo needs to hold on until this child exits
var child = spawn(fixerror);
child
.on('error', function (e) {
//I need to error out here
})
.on('close', function (e) {
//I need to have foo continue here
});
} else {
return "bar";
}
});
How would I go about doing that?