Skip to content
This repository has been archived by the owner on Nov 19, 2024. It is now read-only.

Commit

Permalink
Add a rake task for unused includes
Browse files Browse the repository at this point in the history
  • Loading branch information
dshevtsov committed Jan 4, 2022
1 parent bde3bfe commit d448e0e
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions rakelib/test.rake
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,25 @@ namespace :test do
end
puts "Found #{images.size} dangling images".red
end

desc 'Find unused includes'
task :unused_includes do
puts 'Running a task to find unused images'.magenta
includes = Dir['src/_includes/**/*']
puts "The project contains a total of #{includes.size} includes"
puts "Let's see how many are unused..."
Dir['src/**/*.{md,html}'].each do |file|
# Exclude symmlinks
next if File.symlink? file

includes.delete_if { |include| File.read(file).include?(File.basename(include)) }
end

abort 'No unlinked includes' if includes.empty?

includes.each do |include|
puts "No links for #{include}".yellow
end
puts "Found #{includes.size} unlinked includes".red
end
end

0 comments on commit d448e0e

Please sign in to comment.