File tree Expand file tree Collapse file tree 1 file changed +11
-8
lines changed Expand file tree Collapse file tree 1 file changed +11
-8
lines changed Original file line number Diff line number Diff line change 1- #! /bin/bash
1+ #! /usr/bin/env bash
2+
3+ set -uo pipefail
4+ IFS=$' \n\t '
25
36check_git_history=false
47
@@ -9,19 +12,17 @@ rm -f tmp-unused-images-history
912# Exceptions are ignored, and for .svg files we also look for potential .png
1013# files with the same base name, as they might be sources.
1114
12- exceptions=" docs_logo.svg tween_cheatsheet.png"
13-
14- files=$( find -name " _build" -prune -o \( -name " *.png" -o -name " *.jpg" -o -name " *.svg" -o -name " *.gif" \) -print | sort)
15+ files=$( find -name " _build" -prune -o \( -iname " *.png" -o -iname " *.webp" -o -iname " *.jpg" -o -iname " *.svg" -o -iname " *.gif" \) -print | sort)
1516
1617for path in $files ; do
17- file=$( basename $path )
18- if echo " $exceptions " | grep -q " $file " ; then
18+ file=$( basename " $path " )
19+ if [[ " $path " == * ./img/ * ]] ; then
1920 continue
2021 fi
2122 ext=${file##* .}
2223 base=${file% .* }
2324 found=$( rg -l " :: .*[ /]$file " )
24- if [ -z " $found " -a " $ext " == " svg" ]; then
25+ if [ -z " $found " ] && [ " $ext " == " svg" ]; then
2526 # May be source file.
2627 found=$( rg -l " :: .*[ /]$base .png" )
2728 fi
@@ -30,11 +31,13 @@ for path in $files; do
3031 fi
3132done
3233
34+ echo " Wrote list of unused images to: tmp-unused-images"
3335
3436if [ " $check_git_history " = true ]; then
3537 for file in $( cat tmp-unused-images) ; do
3638 echo " File: $file "
37- git log --diff-filter=A --follow $file
39+ git log --diff-filter=A --follow " $file "
3840 echo
3941 done > tmp-unused-images-history
42+ echo " Wrote list of unused images in Git history to: tmp-unused-images-history"
4043fi
You can’t perform that action at this time.
0 commit comments