Is there a 404 link checker for gulp? I'm looking for something like grunt's grunt-link-checker for those unfamiliar it provides a list of internal and external links that 404.
A gulpfile is just javascript. So you could easily make a task for this:
var gulp = require('gulp');
var gutil = require('gulp-util');
var Crawler = require('simplecrawler');
gulp.task('checklinks', function(cb) {
Crawler.crawl('http://example.com/')
.on('fetch404', function(queueItem, response) {
gutil.log('Resource not found linked from ' +
queueItem.referrer + ' to', queueItem.url);
gutil.log('Status code: ' + response.statusCode);
})
.on('complete', function(queueItem) {
cb();
});
});
grunt-link-checker uses https://github.com/cgiffard/node-simplecrawler. We can just use its API directly in the gulpfile.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With