diff --git a/lib/utils.js b/lib/utils.js index 6cde738d13..f6aa4ef0e6 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -37,10 +37,9 @@ exports.promisifyRouteParams = function (fn) { if (Array.isArray(fn)) { return Promise.resolve(fn) } - let promise // If routeParams[route] is a function expecting a callback if (fn.length === 1) { - promise = new Promise((resolve, reject) => { + return new Promise((resolve, reject) => { fn(function (err, routeParams) { if (err) { reject(err) @@ -48,9 +47,8 @@ exports.promisifyRouteParams = function (fn) { resolve(routeParams) }) }) - } else { - promise = fn() } + let promise = fn() if (!(promise instanceof Promise)) { promise = Promise.resolve(promise) }