Nenhuma descrição

test.sh 1.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. TEST_APP_NAME='RNFetchBlobTest'
  2. TEST_APP_PATH="$(pwd)/${TEST_APP_NAME}"
  3. TARGET='android'
  4. CWD=$(pwd)
  5. if [ "$#" -eq 1 ]; then
  6. if [ "$1" == 'android' ]; then
  7. TARGET="$1"
  8. echo 'start android test'
  9. elif [ "$1" == 'ios' ]; then
  10. TARGET="$1"
  11. echo 'start ios test'
  12. else
  13. exit "unrecongized target platform $1, please specify a target platform `ios` or `android`."
  14. fi
  15. elif [ "$#" -gt 2 ] && [ "$1" == 'path' ]; then
  16. TEST_APP_PATH="$2"
  17. TARGET="$3"
  18. echo "use exist test app path=$2 target=$3"
  19. else
  20. exit "unrecongized arguments."
  21. fi
  22. # Create new rn project
  23. if [ "$#" -eq 1 ]; then
  24. echo 'creating test app RNFetchBlobTest ..'
  25. rm -rf "${TEST_APP_NAME}"
  26. react-native init "${TEST_APP_NAME}"
  27. fi
  28. # copy js files to test app folder
  29. cp -R test/ "${TEST_APP_PATH}/"
  30. # install module
  31. cd "${TEST_APP_PATH}"
  32. npm install --save "${CWD}/src"
  33. rnpm link
  34. # start RN
  35. cd "${TEST_APP_PATH}"
  36. if [ "$#" == 4 ]; then
  37. sed -i.bak "s/${TEST_APP_NAME}/$4/" ./index.test.js
  38. fi
  39. react-native "run-${TARGET}"
  40. # start test server
  41. cd "${CWD}/test-server"
  42. # kill existing server
  43. kill "$(lsof | grep :8123 | awk '{ printf $2 }')"
  44. node server