Skip to content

Instantly share code, notes, and snippets.

@xavianaxw
Last active August 9, 2022 23:57
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
Git hook to compile blendid assets on file change only
#!/bin/bash
# flag to see if compiling is required
should_precompile=0
wp_directory="wp-content/themes/securepay"
# check if there are changes
# wp-content/themes/securepay/css/*
if git diff-index --name-only HEAD | egrep "$wp_directory/css" >/dev/null ; then
should_precompile=1
echo "$wp_directory/css changed"
fi
# wp-content/themes/securepay/style.css
if git diff-index --name-only HEAD | egrep "$wp_directory/style.css" >/dev/null ; then
should_precompile=1
echo "$wp_directory/style.css changed"
fi
if [ $should_precompile -eq 1 ]; then
# source nvm and .nvmrc if present
[ -s "$HOME/.nvm/nvm.sh" ] && \. "$HOME/.nvm/nvm.sh"
nvm use
echo 'Compiling assets ...'
yarn build
git add --all
fi
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment