Skip to content

Commit

Permalink
docs: add debug lines
Browse files Browse the repository at this point in the history
  • Loading branch information
addetz committed Oct 22, 2024
1 parent 3fe11cb commit 4335f15
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions scripts/find-unused-images.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ git fetch --all

# List all the version branches
branches="master"
version_branches=$(git branch --list "version-[0-9]-[0-9]")
version_branches=$(git branch -a | grep -E 'version-[0-9]+(-[0-9]+)*$')
echo "Version branches: $version_branches"
branches+=" $version_branches"
echo "Branches: $branches"

for current_branch in $branches; do
echo "Current branch: $current_branch"
Expand All @@ -24,23 +26,25 @@ for current_branch in $branches; do
find docs -type f -name "*.md" -exec grep -Hn "\.webp" {} + > docs_used_images.json
find _partials -type f -name "*.mdx" -exec grep -Hn "\.webp" {} + > partials_used_images.json
cat docs_used_images.json partials_used_images.json > used_images.json
echo "Created used_images.json"

line_number=1
for img in $(cat all_images.json); do
if grep -q $img used_images.json; then
sed -i .bak "${line_number}s|.*|${img},FOUND_USED|" all_images.json
sed -i "${line_number}s|.*|${img},FOUND_USED|" all_images.json
fi
((line_number++))
done

echo "Finished processing branch $current_branch"

done

# Remove all marked used files to make up the list
sed '/FOUND_USED/d' all_images.json > unused_images.json

# Clean up files
rm all_images.json
rm all_images.json.bak
rm docs_used_images.json
rm partials_used_images.json
rm used_images.json

0 comments on commit 4335f15

Please sign in to comment.