Skip to content

Instantly share code, notes, and snippets.

@silvers
Created July 2, 2013 08:14
Show Gist options
  • Save silvers/5907571 to your computer and use it in GitHub Desktop.
Save silvers/5907571 to your computer and use it in GitHub Desktop.
if git-add *.scss, then compile.
#!/bin/sh
NAME=$(git branch | grep '*' | sed 's/* //')
# don't run on rebase
if [ $NAME != '(no branch)' ]; then
EDITSCSS=$(git --no-pager diff --diff-filter=AM --name-only --no-color --cached | grep 'scss' | wc -l)
if [ $EDITSCSS -ne 0 ]; then
git stash -q --keep-index
# compile css
grunt css
RETVAL=$?
if [ $RETVAL -ne 0 ]; then
git stash pop -q
exit 1
fi
git add .
git stash pop -q
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment