pack.sh 672 B

12345678910111213141516171819202122
  1. #!/usr/bin/env bash
  2. rm game.zip
  3. rm min.js
  4. rm pack.js
  5. cat KeyCode.js manualtween.js colors.js dialog.js sound.js *-scene.js core.js > pack.js
  6. if ! command -v terser &> /dev/null; then
  7. echo "terser not installed!"
  8. read -p "Would you like to run the npm global install? [Y/n]:" -n 1 -r
  9. if [[ $REPLY =~ ^[Yy]$ ]]; then
  10. sudo npm -g install terser webpack terser-webpack-plugin
  11. else
  12. echo ""
  13. exit 1
  14. fi
  15. fi
  16. #npm -g install terser webpack terser-webpack-plugin
  17. terser --compress --mangle toplevel --output min.js -- pack.js
  18. zip game.zip min.js index.html
  19. SIZE=`ls -la game.zip | awk '{print $5}'`
  20. PERCENT=`expr \( $SIZE \* 100 \) / 13312`
  21. echo $SIZE / 13312 = $PERCENT%