Skip to content
This repository was archived by the owner on Dec 4, 2017. It is now read-only.

Commit 81b011c

Browse files
chalinwardbell
authored andcommitted
chore(linkChecker): fix to checker config
closes #1842 This PR eliminates false positives by adjusting the checker config options: - Some sites don’t support `HEAD` so use the `GET` method. - Exclude known problematic URLs from being checked.
1 parent 86f8212 commit 81b011c

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

gulpfile.js

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -596,7 +596,18 @@ gulp.task('test-api-builder', function (cb) {
596596
// angular.io: gulp link-checker
597597
// local site: gulp link-checker --url=http://localhost:3000
598598
gulp.task('link-checker', function(done) {
599-
return linkChecker();
599+
var method = 'get'; // the default 'head' fails for some sites
600+
var exclude = [
601+
// Dart API docs aren't working yet; ignore them
602+
'*/dart/latest/api/*',
603+
// Somehow the link checker sees ng1 {{...}} in the resource page; ignore it
604+
'resources/%7B%7Bresource.url%7D%7D',
605+
// API docs have links directly into GitHub repo sources; these can
606+
// quickly become invalid, so ignore them for now:
607+
'*/angular/tree/*'
608+
];
609+
var blcOptions = { requestMethod: method, excludedKeywords: exclude};
610+
return linkChecker({ blcOptions: blcOptions });
600611
});
601612

602613

@@ -727,12 +738,8 @@ function linkChecker(options) {
727738
var blcOptions = options.blcOptions || {};
728739
var customData = options.customData || {};
729740

730-
var excludeBad; // don't bother reporting bad links matching this RegExp
731-
if (argv.excludeBad) {
732-
excludeBad = new RegExp(argv.excludeBad);
733-
} else {
734-
excludeBad = options.excludeBad === undefined ? /docs\/dart\/latest\/api/ : '';
735-
}
741+
// don't bother reporting bad links matching this RegExp
742+
var excludeBad = argv.excludeBad ? new RegExp(argv.excludeBad) : (options.excludeBad || '');
736743

737744
var previousPage;
738745
var siteUrl = argv.url || options.url || 'https://angular.io/';
@@ -779,7 +786,8 @@ function linkChecker(options) {
779786
var outputFile = path.join(process.cwd(), 'link-checker-results.txt');
780787
var header = 'Link checker results for: ' + siteUrl +
781788
'\nStarted: ' + (new Date()).toLocaleString() +
782-
'\nSkipping bad links matching regex: ' +excludeBad.toString() + '\n\n';
789+
'\nExcluded links (blc file globs): ' + blcOptions.excludedKeywords +
790+
'\nExcluded links (custom --exclude-bad regex): ' + excludeBad.toString() + '\n\n';
783791
gutil.log(header);
784792
fs.writeFileSync(outputFile, header);
785793

0 commit comments

Comments
 (0)