build.sh 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. #!/bin/bash
  2. # test wepy new demo
  3. # Start in tasks/ even if run from root directory
  4. cd "$(dirname "$0")"
  5. function cleanup() {
  6. echo 'Cleaning up.'
  7. }
  8. # Error messages are redirected to stderr
  9. function handle_error() {
  10. echo "$(basename $0): ERROR! An error was encountered executing line $1." 1>&2;
  11. cleanup
  12. echo 'Exiting with error.' 1>&2;
  13. exit 1
  14. }
  15. function handle_exit() {
  16. cleanup
  17. echo 'Exiting without error.' 1>&2;
  18. exit
  19. }
  20. # Exit the script with a helpful error message when any error is encountered
  21. trap 'set +x; handle_error $LINENO $BASH_COMMAND' ERR
  22. # Cleanup before exit on any termination signal
  23. trap 'set +x; handle_exit' SIGQUIT SIGTERM SIGINT SIGKILL SIGHUP
  24. # Echo every command being executed
  25. set -x
  26. # Go to root
  27. cd ..
  28. root_path=$PWD
  29. npm link packages/cli
  30. wepy -v
  31. wepy list
  32. mkdir -p /tmp/templates/
  33. cd /tmp/templates/
  34. buildcases="${root_path}/test/build-cases"
  35. for bc in ${buildcases}/*; do
  36. name=$(basename $bc .sh)
  37. "$root_path"/test/build-cases/"$name".sh
  38. cd "/tmp/templates/${name}"
  39. node "$root_path"/packages/cli/bin/wepy.js build
  40. done
  41. # Test build demos
  42. cd /tmp/templates
  43. # node "$root_path"/packages/cli/bin/wepy.js init wepyjs/wepy-wechat-demo wepy-wechat-demo
  44. git clone https://github.com/wepyjs/wepy-wechat-demo.git --branch 2.0
  45. cd wepy-wechat-demo
  46. npm install
  47. npm run build
  48. cd ..
  49. # Cleanup
  50. cleanup