#!/bin/bash
#
# Runs Inkscape vacuum to clean up svgs

CDIR=$(git rev-parse --show-toplevel)

echo "Running Inkscape vacuum. This may take some time..."

git diff --cached --name-status --diff-filter=ACMR | while read STATUS FILE; do
  if [[ "$FILE" =~ ^.+(svg)$ ]]; then
    inkscape --vacuum-defs -z $CDIR/$FILE --export-plain-svg=$CDIR/$FILE
  fi
done

git add .
exit 0
