Skip to content

Commit

Permalink
Update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
s0ph1e committed Oct 28, 2015
1 parent c56bf82 commit 16a28ef
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 15 deletions.
6 changes: 3 additions & 3 deletions lib/file-handlers/css.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
var Promise = require('bluebird');
var _ = require('underscore');
var Promise = require('bluebird');
var getCssUrls = require('css-url-parser');
var Resource = require('../resource');
var utils = require('../utils');
Expand All @@ -22,10 +22,10 @@ function loadCss (context, resource) {
});
});

return Promise.settle(promises).then(function () {
return utils.waitAllFulfilled(promises).then(function () {
resource.setText(text);
return resource;
});
}

module.exports = loadCss;
module.exports = loadCss;
6 changes: 3 additions & 3 deletions lib/file-handlers/html.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
var Promise = require('bluebird');
var cheerio = require('cheerio');
var Promise = require('bluebird');
var utils = require('../utils');
var Resource = require('../resource');

Expand Down Expand Up @@ -63,11 +63,11 @@ function loadResources (context, resource, source) {
return Promise.reject();
});

return Promise.settle(promises).then(function () {
return utils.waitAllFulfilled(promises).then(function () {
text = $.html();
resource.setText(text);
return resource;
});
}

module.exports = loadHtml;
module.exports = loadHtml;
9 changes: 5 additions & 4 deletions lib/request.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
var _ = require('underscore');
var Promise = require('bluebird');
var request = Promise.promisifyAll(require('request'));
var request = require('request');
var get = Promise.promisify(request.get);

var defaultOptions = {
method: 'GET',
Expand All @@ -21,10 +22,10 @@ function makeRequest(options, url) {
var requestOptions = getCustomOptions(options);
requestOptions.url = url;

return request.getAsync(requestOptions).then(function (data) {
return get(requestOptions).then(function handleResponse(data) {
return {
url: data[0].request.href,
body: data[0].body
url: data.request.href,
body: data.body
};
});
}
Expand Down
2 changes: 1 addition & 1 deletion lib/scraper.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ Scraper.prototype.scrape = function scrape(callback) {
.then(self.prepare)
.then(self.load)
.catch(self.errorCleanup)
.nodeify(callback);
.asCallback(callback);
};

module.exports = Scraper;
10 changes: 9 additions & 1 deletion lib/utils.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
var url = require('url');
var path = require('path');
var Promise = require('bluebird');

function isUrl(path) {
var urlRegexp = /^((http[s]?:)?\/\/)/;
Expand Down Expand Up @@ -29,10 +30,17 @@ function getFilenameFromUrl (u) {
return path.basename(url.parse(u).pathname);
}

function waitAllFulfilled(promises) {
return Promise.all(promises.map(function(promise) {
return promise.reflect();
}));
}

module.exports = {
isUrl: isUrl,
getUrl: getUrl,
getUnixPath: getUnixPath,
getRelativePath: getRelativePath,
getFilenameFromUrl: getFilenameFromUrl
getFilenameFromUrl: getFilenameFromUrl,
waitAllFulfilled: waitAllFulfilled
};
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,17 @@
},
"homepage": "https://github.com/s0ph1e/node-website-scraper",
"dependencies": {
"bluebird": "^2.3.2",
"bluebird": "^3.0.1",
"cheerio": "0.11.0",
"compare-urls": "^1.0.0",
"css-url-parser": "^0.1.0",
"fs-extra": "^0.22.1",
"fs-extra": "^0.26.0",
"request": "^2.42.0",
"underscore": "^1.7.0"
},
"devDependencies": {
"codeclimate-test-reporter": "^0.1.0",
"istanbul": "^0.3.17",
"istanbul": "^0.4.0",
"mocha": "^2.2.5",
"nock": "^2.9.1",
"should": "^7.0.2",
Expand Down

0 comments on commit 16a28ef

Please sign in to comment.