Created
February 18, 2016 10:21
-
-
Save temoto/ae5ee4117f2660f7e7ce to your computer and use it in GitHub Desktop.
[website deploy] Find references to missing assets files. Helps to prevent 404 and 500 (pagespeed beacon) errors.
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
#!/bin/bash | |
set -e | |
find . -print0 |fgrep -v --null-data --null '/.hg/' >tmp-asset-clean-all | |
egrep -hIor "/\w+/\w+\.(gif|jpg|jpeg|png|eot|svg|ttf|woff|webm|webp)" |sort -u >tmp-asset-clean-refs | |
for f in $(cat tmp-asset-clean-refs); do | |
dir=${f%%/*} | |
name=${f##*/} | |
if ! egrep --max-count=1 --null-data -q $f tmp-asset-clean-all; then | |
echo -e "\n\n$f not found. References:\n $(egrep -Inr $f)\n\n" | |
fi | |
done | |
rm -f tmp-asset-clean* |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment