Created
December 17, 2014 07:39
-
-
Save johno/216aed66220f562cd500 to your computer and use it in GitHub Desktop.
Use the a11y npm package in a gulpfile.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var gulp = require('gulp'); | |
var gutil = require('gulp-util'); | |
var a11y = require('a11y'); | |
gulp.task('a11y', function() { | |
a11y('http://furtive.co', function(err, reports) { | |
if (err) { | |
gutil.log(gutil.colors.red('gulp a11y error: ' + err)); | |
return; | |
} | |
reports.audit.forEach(function(report) { | |
if (report.result === 'FAIL') { | |
gutil.log(displaySeverity(report), gutil.colors.red(report.heading), report.elements); | |
} | |
}); | |
}); | |
}); | |
function displaySeverity(report) { | |
if (report.severity == 'Severe') { | |
return gutil.colors.red('[' + report.severity + '] '); | |
} else if (report.severity == 'Warning') { | |
return gutil.colors.yellow('[' + report.severity + '] '); | |
} else { | |
return '[' + report.severity + '] '; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment