Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ scrape(options, (error, result) => {
* [onResourceSaved](#onresourcesaved) - callback called when resource is saved
* [onResourceError](#onresourceerror) - callback called when resource's downloading is failed

Default options you can find in [lib/config/defaults.js](https://github.com/s0ph1e/node-website-scraper/blob/master/lib/config/defaults.js).
Default options you can find in [lib/config/defaults.js](https://github.com/s0ph1e/node-website-scraper/blob/master/lib/config/defaults.js) or get them using `scrape.defaults`.

#### urls
Array of objects which contain urls to download and filenames for them. **_Required_**.
Expand Down
2 changes: 2 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ var Scraper = require('./lib/scraper.js');
module.exports = function scrape (options, callback) {
return new Scraper(options).scrape(callback);
};

module.exports.defaults = Scraper.defaults;
2 changes: 2 additions & 0 deletions lib/scraper.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,4 +206,6 @@ Scraper.prototype.scrape = function scrape (callback) {
.asCallback(callback);
};

Scraper.defaults = _.clone(defaults);

module.exports = Scraper;
12 changes: 11 additions & 1 deletion test/unit/scraper-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ var should = require('should');
var sinon = require('sinon');
require('sinon-as-promised');
var nock = require('nock');
var proxyquire = require('proxyquire');
var proxyquire = require('proxyquire').noCallThru();
var fs = require('fs-extra');
var path = require('path');
var Scraper = require('../../lib/scraper');
Expand Down Expand Up @@ -480,4 +480,14 @@ describe('Scraper', function () {
});
});
});

describe('defaults', function() {
it('should export defaults', function() {
var defaultsMock = { subdirectories: null, recursive: true, sources: [] };
Scraper = proxyquire('../../lib/scraper', {
'./config/defaults': defaultsMock
});
should(Scraper.defaults).be.eql({ subdirectories: null, recursive: true, sources: [] });
});
});
});