post-applypatch 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #!/bin/sh
  2. #yorkie 2.0.0
  3. command_exists () {
  4. command -v "$1" >/dev/null 2>&1
  5. }
  6. has_hook_script () {
  7. [ -f package.json ] && cat package.json | grep -q "\"$1\"[[:space:]]*:"
  8. }
  9. # OS X and Linux only
  10. load_nvm () {
  11. # If nvm is not loaded, load it
  12. command_exists nvm || {
  13. export NVM_DIR="$1"
  14. [ -s "$1/nvm.sh" ] && . "$1/nvm.sh"
  15. }
  16. }
  17. # OS X and Linux only
  18. run_nvm () {
  19. # If nvm has been loaded correctly, use project .nvmrc
  20. command_exists nvm && [ -f .nvmrc ] && nvm use
  21. }
  22. cd "."
  23. # Check if post-applypatch is defined, skip if not
  24. has_hook_script post-applypatch || exit 0
  25. # Add common path where Node can be found
  26. # Brew standard installation path /usr/local/bin
  27. # Node standard installation path /usr/local
  28. export PATH="$PATH:/usr/local/bin:/usr/local"
  29. # Try to load nvm using path of standard installation
  30. load_nvm /Users/zweizhao/.nvm
  31. run_nvm
  32. # Export Git hook params
  33. export GIT_PARAMS="$*"
  34. # Run hook
  35. node "./node_modules/yorkie/src/runner.js" post-applypatch || {
  36. echo
  37. echo "post-applypatch hook failed (add --no-verify to bypass)"
  38. exit 1
  39. }