Created
December 10, 2014 14:16
-
-
Save gogiel/a1fa827f5241bc543e4d to your computer and use it in GitHub Desktop.
Find unused assets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Requires `brew install ag` | |
dirname = ARGV[0] | |
records = Dir.glob(File.join(dirname, "**/*")) | |
possible_extensions = %w(jpeg jpg svg gif png css scss js coffee htc ejs jst).map{|ext| ".#{ext}"} | |
names = records.reject{|path| File.directory?(path) }.map do |path| | |
name = File.basename path | |
while true | |
ext = File.extname(name) | |
if possible_extensions.include? ext | |
name = File.basename name, ext | |
else | |
break | |
end | |
end | |
[name, path] | |
end | |
names.each do |data| | |
name, path = data | |
`ag '#{name}' --ignore '*.svg' > /dev/null` | |
if $? != 0 | |
puts path | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment