Nav apraksta

test.sh 1.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. cp -R test/ "${TEST_APP_PATH}/"
  29. # install module
  30. cd "${TEST_APP_PATH}"
  31. npm install --save "${CWD}/src"
  32. rnpm link
  33. # start RN
  34. cd "${TEST_APP_PATH}"
  35. if [ "$#" == 4 ]; then
  36. sed -i.bak "s/${TEST_APP_NAME}/$4/" ./index.test.js
  37. fi
  38. react-native "run-${TARGET}"
  39. # start test server
  40. cd "${CWD}/test-server"
  41. # kill existing server
  42. kill "$(lsof | grep :8123 | awk '{ printf $2 }')"
  43. node server