Skip to content

Instantly share code, notes, and snippets.

@johno
Created December 17, 2014 07:39
Show Gist options
  • Save johno/216aed66220f562cd500 to your computer and use it in GitHub Desktop.
Save johno/216aed66220f562cd500 to your computer and use it in GitHub Desktop.
Use the a11y npm package in a gulpfile.
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