55
66namespace :test do
77 # Run html-proofer to check for broken links
8- desc 'Build devdocs and check for broken links'
8+ desc 'Build site, check for broken links, write report to a file '
99 task links : %w[ build links_no_build ]
1010
11- # Run htmlproofer to check for broken external links
1211 desc 'Check the existing _site for broken EXTERNAL links'
1312 task :external_links do
1413 puts 'Testing external links'
15- system 'bundle exec htmlproofer _site/ --external_only'
14+ system 'bin/ htmlproofer _site/ --external_only'
1615 end
1716
18- desc 'Check the entire _site for broken links and invalid HTML '
17+ desc 'Check the existing _site for broken INTERNAL links '
1918 task :html do
20- puts 'Checking links with html-proofer ...' . magenta
19+ puts 'Checking HTML ...' . magenta
2120
2221 LinkChecker . check_site
2322 end
2423
25- desc 'Check the existing _site for broken links'
24+ desc 'Check the existing _site for broken links and report to a separate file '
2625 task :links_no_build do
2726 begin
2827 # Write console output (stderr only) to a file.
2928 # Use this if you need to also capture stdout: https://stackoverflow.com/a/2480439
3029 report = LinkChecker . md_report_path
3130 $stderr. reopen ( report , 'w+' )
3231
33- puts 'Checking links with html-proofer...' . magenta
34- LinkChecker . check_site
32+ Rake ::Task [ 'test:html' ] . invoke
3533
3634 # We're expecting link validation errors, but unless we rescue from
3735 # StandardError, rake will abort and won't run the convert task (https://stackoverflow.com/a/10048406).
@@ -56,9 +54,14 @@ namespace :test do
5654 print 'List the rules: $ ' . magenta
5755 sh 'bin/mdl -l --style=_checks/styles/style-rules-prod'
5856 puts 'Linting ...' . magenta
59- output = `bin/mdl --style=_checks/styles/style-rules-prod --ignore-front-matter --git-recurse -- .`
57+ output =
58+ `bin/mdl \
59+ --style=_checks/styles/style-rules-prod \
60+ --ignore-front-matter \
61+ --git-recurse \
62+ -- .`
6063 puts output . yellow
61- abort "The Markdown linter detected #{ output . lines . count - 2 } issue(s) " . red unless output . empty?
62- puts 'No issues found' . magenta
64+ abort "Fix the reported issues " . red unless output . empty?
65+ puts 'No issues found' . green
6366 end
6467end
0 commit comments