Last active
August 9, 2022 23:57
-
-
Save xavianaxw/6ca1ec02f7f5a4a2e678a4a079149b01 to your computer and use it in GitHub Desktop.
Git hook to compile blendid assets on file change only
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/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