1#!/bin/bash
2#
3# Runs Inkscape vacuum (twice) to clean up svgs.
4# The first run reorders the elements in the svg and pollutes the diffs, the second
5# run cancels out this effect.
6
7CDIR=$(git rev-parse --show-toplevel)
8
9echo "Running Inkscape vacuum. This may take some time..."
10
11git diff --cached --name-status --diff-filter=ACMR | while read STATUS FILE; do
12  if [[ "$FILE" =~ ^.+(svg)$ ]]; then
13    inkscape --vacuum-defs -z $CDIR/$FILE --export-plain-svg=$CDIR/$FILE
14    inkscape --vacuum-defs -z $CDIR/$FILE --export-plain-svg=$CDIR/$FILE
15  fi
16done
17
18exit 0
19