diff --git a/package.json b/package.json index 17162ab..b6f469a 100644 --- a/package.json +++ b/package.json @@ -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", @@ -15,12 +15,7 @@ "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" }, @@ -28,19 +23,19 @@ "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", diff --git a/tasks/a11y.js b/tasks/a11y.js index d9962a7..a8cf720 100644 --- a/tasks/a11y.js +++ b/tasks/a11y.js @@ -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; @@ -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 = ''; @@ -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; } @@ -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);