Skip to content

Instantly share code, notes, and snippets.

@lajlev
Last active June 15, 2016 07:41
Show Gist options
  • Save lajlev/f5ee1e2e2e315f5274b10ec6d9ca93a0 to your computer and use it in GitHub Desktop.
Save lajlev/f5ee1e2e2e315f5274b10ec6d9ca93a0 to your computer and use it in GitHub Desktop.
#!/bin/sh
# Requires sketch and Sketchtool
# Q: How to enable it?
# A: Add it to your repo pre-commit hook
# Q: What does it do?
# A: It creates a .exportArtboards folder with all artboards as PNGs,
# so you easily can see changes in GIT 🎊.
git diff --cached --name-status | while read STATE FILE; do
# Skip deleted files
if [ "$STATE" == 'D' ]; then continue; fi
# Do a check only on the sketch files files
if [[ ${FILE: -7} == ".sketch" ]]; then
DIR=$(dirname "${FILE}")
sketchtool export artboards $FILE --output="${DIR}/.exportArtboards" --overwriting=YES --trimmed=NO --save-for-web=YES
git add ${DIR}/.exportArtboards
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment