Skip to content

Instantly share code, notes, and snippets.

@Plytas
Created July 24, 2018 20:04
Show Gist options
  • Select an option

  • Save Plytas/c7afe8695a5b87e7c07fd4e6617c16bf to your computer and use it in GitHub Desktop.

Select an option

Save Plytas/c7afe8695a5b87e7c07fd4e6617c16bf to your computer and use it in GitHub Desktop.
runs composer & npm install after doing a git checkout
#!/usr/bin/env bash
# MIT © Sindre Sorhus - sindresorhus.com
changed_files="$(git diff-tree -r --name-only --no-commit-id HEAD@{1} HEAD)"
check_run() {
echo "$changed_files" | grep --quiet "$1" && echo " * changes detected in $1" && echo " * running $2" && eval "$2"
}
check_run composer.lock "composer install"
check_run package.json "npm install"
@Plytas
Copy link
Author

Plytas commented Jul 24, 2018

curl -O https://gist.githubusercontent.com/Plytas/c7afe8695a5b87e7c07fd4e6617c16bf/raw/b7f648743f0fd16e6d45aa98a073283da0d1e961/post-checkout && chmod +x post-checkout && mv post-checkout .git/hooks/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment