10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'lib/precompiled_assets/tasks.rb', line 10
def remove_unused
manifest = Manifest.new
pathnames = LocalPath.pathname.glob('**/*').sort
pathnames.select(&:file?).each do |asset_pathname|
next if manifest.pathname == asset_pathname
next if manifest.includes_digested_path?(asset_pathname)
next if manifest.includes_digested_path?(asset_pathname.to_s.delete_suffix('.map'))
puts "Removing unused asset: #{asset_pathname}"
asset_pathname.delete
end
pathnames.select(&:directory?).reverse_each do |directory|
next unless directory.empty?
puts "Removing empty directory: #{directory}"
directory.rmdir
end
end
|