From a0643c945ed0a7a5002223669cbbc0ed3014b3d2 Mon Sep 17 00:00:00 2001 From: Jonah Stiennon Date: Thu, 30 Jun 2016 17:28:11 -0700 Subject: [PATCH] fix use of promises with requestretry module --- package.json | 2 +- src/utils.js | 15 +++++++-------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/package.json b/package.json index e0ea513..25bfec5 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,7 @@ "colors": "~1.1.2", "lodash": "~4.0.0", "q": "~1.4.1", - "requestretry": "~1.6.0", + "requestretry": "~1.9.0", "sauce-tunnel": "~2.4.0", "saucelabs": "~1.0.1" }, diff --git a/src/utils.js b/src/utils.js index 67cc9ee..a5e4d34 100644 --- a/src/utils.js +++ b/src/utils.js @@ -80,18 +80,17 @@ module.exports = function (grunt) { * body. */ function makeRequest(params) { + var QPromiseFactory = function(resolver) { + return q.Promise(resolver); + }; params.retryStrategy = loggingRetryStrategy; - return q - .nfcall(request, params) - .then(function (result) { - var response = result[0]; - var body = result[1]; - + params.promiseFactory = QPromiseFactory; + return request(params) + .then(function (response) { if (response.statusCode !== 200) { throw new Error('HTTP error (' + response.statusCode + ')'); } - - return body; + return response.body; }) .fail(function (error) { throw new WrapperError([