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

Commit 68235d0

Browse files
authored
Merge branch 'master' into imported-ravi-chandra3197-devdocs-9293
2 parents a9b511d + f57615b commit 68235d0

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

rakelib/test.rake

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,25 @@ namespace :test do
6262
abort 'Fix the reported issues'.red unless output.empty?
6363
puts 'No issues found'.green
6464
end
65+
66+
desc 'Find unused images'
67+
task :unused_images do
68+
puts 'Running a task for finding unused images'.magenta
69+
images = Dir['src/**/*.{png,svg,jpeg,jpg,ico}']
70+
puts "The project contains a total of #{images.size} images."
71+
puts 'Checking for unlinked images...'
72+
Dir['src/**/*.{md,html,js,css}'].each do |file|
73+
# Exclude symmlinks
74+
next if File.symlink? file
75+
76+
images.delete_if { |image| File.read(file).include?(File.basename(image)) }
77+
end
78+
79+
abort 'No unlinked images' if images.empty?
80+
81+
images.each do |image|
82+
puts "No links for #{image}".yellow
83+
end
84+
puts "Found #{images.size} dangling images".red
85+
end
6586
end

0 commit comments

Comments
 (0)