Skip to content

Commit

Permalink
feat(index.js): add reporter based on grunt axe connect
Browse files Browse the repository at this point in the history
  • Loading branch information
felixzapata committed Aug 9, 2016
1 parent afab3f9 commit 2519303
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ var fileUrl = require('file-url');
var AxeBuilder = require('axe-webdriverjs');
var WebDriver = require('selenium-webdriver');
var Promise = require('promise');
var reporter = require('./lib/reporter');
var PLUGIN_NAME = 'gulp-axe-core';

var driver = new WebDriver.Builder()
Expand All @@ -14,18 +15,31 @@ var promises = [];
var promise;
var url = '';

module.exports = function (options) {
module.exports = function (customOptions) {

var createResults = function(cb) {
var result;
Promise.all(promises).then(function(results) {
fs.writeFileSync(dest, JSON.stringify(results, null, ' '));
if(options.createReportFile) {
fs.writeFileSync(dest, JSON.stringify(results, null, ' '));
}
result = reporter(results, options.threshold);
driver.quit().then(function() {
cb(result);
});
});
cb();
};

var defaultOptions = {
browser: 'firefox',
server: null,
createReportFile: false,
threshold: 0
};

var options = customOptions ? Object.assign(defaultOptions, customOptions) : defaultOptions;

return through.obj(function (file, enc, cb) {
if (file.isNull()) {
cb(null, file);
Expand All @@ -50,7 +64,6 @@ module.exports = function (options) {
results.url = url;
results.timestamp = new Date().getTime();
results.time = results.timestamp - startTimestamp;
console.log(results);
resolve(results);
});
});
Expand Down

0 comments on commit 2519303

Please sign in to comment.