@@ -220,9 +220,19 @@ HttpEngine.prototype.step = function step(requestSpec, ee, opts) {
220
220
return function ( context , callback ) {
221
221
let processFunc = self . config . processor [ requestSpec . function ] ;
222
222
if ( processFunc ) {
223
- return processFunc ( context , ee , function ( hookErr ) {
224
- return callback ( hookErr , context ) ;
225
- } ) ;
223
+ if ( processFunc . constructor . name === 'Function' ) {
224
+ return processFunc ( context , ee , function ( hookErr ) {
225
+ return callback ( hookErr , context ) ;
226
+ } ) ;
227
+ } else {
228
+ return processFunc ( context , ee )
229
+ . then ( ( ) => {
230
+ callback ( null , context ) ;
231
+ } )
232
+ . catch ( ( err ) => {
233
+ callback ( err , context ) ;
234
+ } ) ;
235
+ }
226
236
} else {
227
237
debug ( `Function "${ requestSpec . function } " not defined` ) ;
228
238
debug ( 'processor: %o' , self . config . processor ) ;
@@ -309,12 +319,16 @@ HttpEngine.prototype.step = function step(requestSpec, ee, opts) {
309
319
console . log ( `WARNING: custom function ${ fn } could not be found` ) ; // TODO: a 'warning' event
310
320
}
311
321
312
- processFunc ( requestParams , context , ee , function ( err ) {
313
- if ( err ) {
314
- return next ( err ) ;
315
- }
316
- return next ( null ) ;
317
- } ) ;
322
+ if ( processFunc . constructor . name === 'Function' ) {
323
+ processFunc ( requestParams , context , ee , function ( err ) {
324
+ if ( err ) {
325
+ return next ( err ) ;
326
+ }
327
+ return next ( null ) ;
328
+ } ) ;
329
+ } else {
330
+ processFunc ( requestParams , context , ee ) . then ( next ) . catch ( next ) ;
331
+ }
318
332
} ,
319
333
function done ( err ) {
320
334
if ( err ) {
@@ -608,12 +622,24 @@ HttpEngine.prototype.step = function step(requestSpec, ee, opts) {
608
622
// Got does not have res.body which Request.js used to have, so we attach it here:
609
623
res . body = body ;
610
624
611
- processFunc ( requestParams , res , context , ee , function ( err ) {
612
- if ( err ) {
613
- return next ( err ) ;
614
- }
615
- return next ( null ) ;
616
- } ) ;
625
+ if ( processFunc . constructor . name === 'Function' ) {
626
+ processFunc (
627
+ requestParams ,
628
+ res ,
629
+ context ,
630
+ ee ,
631
+ function ( err ) {
632
+ if ( err ) {
633
+ return next ( err ) ;
634
+ }
635
+ return next ( null ) ;
636
+ }
637
+ ) ;
638
+ } else {
639
+ processFunc ( requestParams , res , context , ee )
640
+ . then ( next )
641
+ . catch ( next ) ;
642
+ }
617
643
} ,
618
644
function ( err ) {
619
645
if ( err ) {
0 commit comments