Skip to content

Commit

Permalink
Make calls to pahntomas sequential. Keep results of each run, succeed…
Browse files Browse the repository at this point in the history
…ed or

failed.
  • Loading branch information
vinvol committed Apr 9, 2015
1 parent ca0f96a commit da6bc50
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions tasks/lib/phantomas.js
Original file line number Diff line number Diff line change
Expand Up @@ -303,9 +303,9 @@ Phantomas.prototype.executePhantomas = function() {
var runs = [],
callPhantomas = function( url, options ) {
return function() {
return new Promise(function(resolve) {
return phantomas( url, options ).then(resolve);
});
return new Promise( function( resolve, reject ) {
return phantomas( url, options ).then( resolve, reject );
} );
};
};

Expand All @@ -329,12 +329,15 @@ Phantomas.prototype.executePhantomas = function() {
runs.push( callPhantomas( this.options.url, options ) );
}

Promise.reduce( runs, function( total, run, index ) {
runs[ index ] = run();
return runs[ index ];
}, []).then(function() {
Promise.each( runs,
function( run, index ) {
runs[ index ] = run();
return runs[ index ].reflect();
} ).then( function() {
Promise.settle( runs ).then( resolve );
});
} ).catch( function( e ) {
console.log(e);
} );
}.bind( this ) );
};

Expand Down

0 comments on commit da6bc50

Please sign in to comment.