Created
September 23, 2020 16:16
-
-
Save politician/f09f7f8d28dce3ec0e77072eddfbeee9 to your computer and use it in GitHub Desktop.
Pre-commit hook to build and add folder to the current 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
# This script is used for repos that need to commit a build folder (eg. Github actions) | |
# Add more sources/destinations by separating them by spaces (ie. source="src lib") | |
source="src" | |
build="dist" | |
# If some changes in $source are staged | |
if [[ $(git status --porcelain $source | egrep '^M') ]] | |
then | |
# Run build command | |
echo "Verifying $build is built and committed..." | |
yarn build -q | |
# If this generated unstaged changes in $build folder(s) | |
if [[ $(git status --porcelain $build | egrep '^(([M ]M)|\?\?)') ]] | |
then | |
yarn test | |
git add $build | |
echo "ℹ️ Added $build to your commit" | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment