test-build.sh 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. exps="${root_path}/scripts/exps"
  35. for exp in ${exps}/*; do
  36. name=$(basename $exp .exp)
  37. expect "$root_path"/scripts/exps/"$name".exp "/tmp/templates/${name}"
  38. pwd
  39. ls -la
  40. cd "/tmp/templates/${name}"
  41. npm install
  42. node "$root_path"/packages/cli/bin/wepy.js build
  43. done
  44. # Build multiple version for standard project.
  45. cd /tmp/templates/standard
  46. node "$root_path"/packages/cli/bin/wepy.js build
  47. # Test build demos
  48. cd /tmp/templates
  49. # node "$root_path"/packages/cli/bin/wepy.js init wepyjs/wepy-wechat-demo wepy-wechat-demo
  50. git clone https://github.com/wepyjs/wepy-wechat-demo.git --branch 2.0
  51. cd wepy-wechat-demo
  52. npm install
  53. npm run build
  54. cd ..
  55. # Cleanup
  56. cleanup