torch 921 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #!/bin/bash
  2. set -e
  3. root=$(cd $(dirname ${0})/..; pwd)
  4. node_modules=${root}/node_modules
  5. src=${root}/src
  6. tools=${root}/tools
  7. third_party=${root}/third_party
  8. identifier=torch
  9. bold() {
  10. echo "$(tty -s && tput bold)$1$(tty -s && tput sgr0)"
  11. }
  12. git_sync() {
  13. mkdir -p "${third_party}"
  14. if [ -d "${third_party}/${1}" ]; then
  15. git -C "${third_party}/${1}" fetch -p --quiet
  16. git -C "${third_party}/${1}" reset --quiet --hard origin/master
  17. else
  18. echo "Clone ${2}..."
  19. git -C "${third_party}" clone --recursive ${2} ${1}
  20. fi
  21. git -C "${third_party}" submodule update --init
  22. }
  23. clean() {
  24. bold "torch clean"
  25. rm -rf ${third_party}/${identifier}
  26. }
  27. sync() {
  28. bold "torch sync"
  29. git_sync torch https://github.com/torch/torch7.git
  30. }
  31. while [ "$#" != 0 ]; do
  32. command="$1" && shift
  33. case "${command}" in
  34. "clean") clean;;
  35. "sync") sync;;
  36. esac
  37. done