|
|
|
@ -5,13 +5,14 @@ const through2 = require("through2");
|
|
|
|
|
const assureArray = require("assure-array");
|
|
|
|
|
|
|
|
|
|
function wrapStreamHandler(stream, handler, callback, item) {
|
|
|
|
|
return Promise.try(() => {
|
|
|
|
|
Promise.try(() => {
|
|
|
|
|
return handler(item);
|
|
|
|
|
}).then((result) => {
|
|
|
|
|
return assureArray(result);
|
|
|
|
|
}).each((newItem) => {
|
|
|
|
|
stream.push(newItem);
|
|
|
|
|
}).then(() => {
|
|
|
|
|
// TODO: Fix the "a promise was created in a handler at [...] but was not returned from it" Bluebird warning that occurs here
|
|
|
|
|
callback();
|
|
|
|
|
}).catch((err) => {
|
|
|
|
|
callback(err);
|
|
|
|
|