#!/bin/bash # # An example hook script to verify what is about to be committed. # Called by "git commit" with no arguments. The hook should # exit with non-zero status after issuing an appropriate message if # it wants to stop the commit. # # To enable this hook, rename this file to "pre-commit". set -e [ -n "$NO_HOOK" ] && exit 0 [ -n "$WECHATY_INNER_PRE_HOOK" ] && { # http://stackoverflow.com/a/21334985/1123955 exit 0 } npm run lint [ -z "$CYGWIN" ] && { npm version patch git rebase WECHATY_INNER_PRE_HOOK=1 git push echo echo echo echo " ### Npm verion bumped and pushed by inner push inside hook pre-push ###" echo " ------- vvvvvvv outer push will be canceled, never mind vvvvvvv -------" echo echo echo exit 127 } # must run this after the above `test` ([ -z ...]), # or will whow a error: error: failed to push some refs to 'git@github.com:wechaty/wechaty.git' echo "PRE-PUSH HOOK PASSED" echo