summaryrefslogtreecommitdiff
path: root/pre-commit
blob: 0e3725b583eb127daa4dba2e07e33ce1e36e4101 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/bin/bash
#
# Runs Inkscape vacuum (twice) to clean up svgs.
# The first run reorders the elements in the svg and pollutes the diffs, the second
# run cancels out this effect.

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
    inkscape --vacuum-defs -z $CDIR/$FILE --export-plain-svg=$CDIR/$FILE
  fi
done

exit 0