build.sh 772 B

12345678910111213141516171819202122
  1. #!/bin/bash
  2. exec 2>&1
  3. # If the repo is not there then we have nothing to build. Exit
  4. [ ! -d "./peerjs" ] && echo "PeerJS source code not found at ./peerjs. Clone it from https://github.com/peers/peerjs.git" && exit
  5. rm -rf dist/
  6. cd peerjs
  7. # Generate a file documenting the changes made to peerjs source code for future reference
  8. git diff -- . ':(exclude)dist/*' > ../patch/base_code_changes.diff
  9. # Build the existing peerjs project into ../dist
  10. ../node_modules/.bin/parcel build --no-source-maps lib/exports.ts -d ../dist --out-file peerjs.min.js
  11. cd ../
  12. # Append some of our modifications onto the built peerjs code
  13. cat patch/header_patch.js dist/peerjs.min.js patch/footer_patch.js > dist/peerjs-on-node.js
  14. rm dist/peerjs.min.js
  15. echo "Done. dist/peerjs-on-node.js"