Last active
December 11, 2015 12:58
-
-
Save asaaki/4603721 to your computer and use it in GitHub Desktop.
Exports *.bmml files to PNGs when staged for git commit
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# .git/hooks/pre-commit | |
# | |
# NEEDS registered version of Balsamiq Mockups (mandatory for PNG export) | |
# | |
# Exports *.bmml files to PNGs, but only for new or modified ones (files in stage area). | |
# This should be installed as .git/hooks/pre-commit in your local repository (with +x flag). | |
# As git hook it ensures that your new/modified (and staged) files will be exported before commit | |
# your changes to the repository automatically. | |
# | |
# INSTALL | |
# | |
# $ cd /to/your/repo/with/mockups | |
# $ curl https://gist.github.com/raw/4603721/pre-commit -o .git/hooks/pre-commit | |
# $ chmod +x .git/hooks/pre-commit | |
# | |
# USAGE | |
# | |
# * Edit/create your mockups | |
# * Prepare commit and `git add` the files you want to commit (stage them!) | |
# * Commit -> the hook is triggered and creates the PNGs | |
# for OSX only: | |
mockupsApp="/Applications/Balsamiq Mockups.app/Contents/MacOS/Balsamiq Mockups" | |
cdir=`pwd` | |
files=`git diff HEAD --cached --name-only | awk '$0~/bmml/{print}' | sed -e 's/ /%20/g'` | |
for f in $files; do | |
ifile=`echo ${cdir}/${f} | sed -e 's/%20/\\\ /g'` | |
ofile=`echo $ifile | sed -e 's/bmml/png/'` | |
echo "Converting" | |
echo " $ifile" | |
echo " to $ofile" | |
`"$mockupsApp" export "$ifile" "$ofile"` | |
done | |
# Hm, you should not need to use this with a proper BM app setup ... | |
# exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment