Skip to content

Commit

Permalink
Merge pull request #19 from srescio/master
Browse files Browse the repository at this point in the history
update package dependecies and add verbose flag
  • Loading branch information
lucalanca committed Oct 26, 2017
2 parents c2f8202 + 11e966c commit 882fcf5
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 18 deletions.
19 changes: 7 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "grunt-a11y",
"description": "Grunt wrapper for a11y",
"version": "0.1.4",
"version": "0.1.5",
"homepage": "https://github.com/lucalanca/grunt-a11y",
"author": {
"name": "Joao Figueiredo",
Expand All @@ -15,32 +15,27 @@
"bugs": {
"url": "https://github.com/lucalanca/grunt-a11y/issues"
},
"licenses": [
{
"type": "MIT",
"url": "https://github.com/lucalanca/grunt-a11y/blob/master/LICENSE-MIT"
}
],
"license": "MIT",
"engines": {
"node": ">= 0.8.0"
},
"scripts": {
"test": "grunt test"
},
"devDependencies": {
"grunt": "^0.4.5",
"grunt": "^1.0.1",
"grunt-contrib-clean": "^1.0.0",
"grunt-contrib-jshint": "^0.12.0",
"grunt-contrib-nodeunit": "^0.4.1"
"grunt-contrib-nodeunit": "^1.0.0"
},
"peerDependencies": {
"grunt": "~0.4.5"
"grunt": "^1.0.1"
},
"keywords": [
"gruntplugin"
"gruntplugin", "accessibility", "a11y"
],
"dependencies": {
"a11y": "^0.4.0",
"a11y": "^0.5.0",
"chalk": "^1.0.0",
"globby": "^4.0.0",
"indent-string": "^2.1.0",
Expand Down
18 changes: 12 additions & 6 deletions tasks/a11y.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,16 @@ module.exports = function(grunt) {
* A promise-based wrapper on a11y.
* @param {String} url
* @param {String} viewportSize
* @param {Boolean} verbose
* @return {Promise}
*/
function a11yPromise (url, viewportSize) {
function a11yPromise (url, viewportSize, verbose) {
var deferred = Q.defer();
a11y(url, {viewportSize: viewportSize}, function (err, reports) {
if (err) {
deferred.reject(new Error(err));
} else {
deferred.resolve({url: url, reports: reports});
deferred.resolve({url: url, reports: reports, verbose: verbose});
}
});
return deferred.promise;
Expand All @@ -48,7 +49,7 @@ module.exports = function(grunt) {
* @param {a11y reports} reports
* @return {Boolean} if the audit is valid
*/
function logReports (url, reports) {
function logReports (url, reports, verbose) {
var passes = '';
var failures = '';

Expand All @@ -67,6 +68,10 @@ module.exports = function(grunt) {
grunt.log.writeln(indent(failures, ' ', 2));
grunt.log.writeln(indent(passes , ' ', 2));

if (verbose) {
grunt.log.writeln('VERBOSE OUTPUT\n', reports.audit);
}

return !failures.length;
}

Expand All @@ -79,19 +84,20 @@ module.exports = function(grunt) {
var options = this.options({
urls: [],
failOnError: false,
viewportSize: '1024x768'
viewportSize: '1024x768',
verbose: false
});

var urls = globby.sync(options.urls, {
nonull: true
}).map(protocolify);
var a11yPromises = urls.map(function (url) {
return a11yPromise(url, options.viewportSize);
return a11yPromise(url, options.viewportSize, options.verbose);
});

a11yPromises.forEach(function (f) {
f.then(function (audit) {
var valid = logReports(audit.url, audit.reports);
var valid = logReports(audit.url, audit.reports, audit.verbose);
if (!valid) {
if (options.failOnError) {
grunt.fail.fatal('FATAL: Audit failed for ' + audit.url);
Expand Down

0 comments on commit 882fcf5

Please sign in to comment.