compile.sh 1.6 KB

12345678910111213141516171819202122232425262728293031
  1. #!/bin/zsh
  2. ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ###
  3. # compile.sh
  4. #
  5. # This script is made to be called by yabai when browser is launched - see
  6. # `yabairc` for details. This often causes the process to fire twice, so the
  7. # program requires a lock. Detailed compilation logs are also kept.
  8. ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ###
  9. SURFINGKEYS_SETTINGS_SERVER_RUN_DIR=$XDG_CONFIG_HOME/surfingkeys/run/ &&
  10. mkdir -p $SURFINGKEYS_SETTINGS_SERVER_RUN_DIR &&
  11. nohup python3 -m http.server -d $SURFINGKEYS_SETTINGS_SERVER_RUN_DIR $SURFINGKEYS_SETTINGS_SERVER_PORT >&/dev/null &
  12. cd $XDG_CONFIG_HOME/surfingkeys/ &&
  13. if mkdir compile.lock 2>/dev/null; then
  14. echo "=== === === === === === === === === === ===" | tee -a compile.log
  15. echo " STARTED " | tee -a compile.log
  16. echo "=== === === === === === === === === === ===" | tee -a compile.log
  17. echo "$(date 2>&1): Compiling" | tee -a compile.log
  18. if [ ! -f package-lock.json ]; then
  19. echo "\t$(npm install 2>&1)" | tee -a compile.log
  20. fi
  21. echo "\t$(npm run build 2>&1)" | tee -a compile.log
  22. rm -rf compile.lock
  23. mv index.js run | tee -a compile.log
  24. echo "=== === === === === === === === === === ===" | tee -a compile.log
  25. echo " FINISHED " | tee -a compile.log
  26. echo "=== === === === === === === === === === ===" | tee -a compile.log
  27. echo "" | tee -a compile.log
  28. tail -c 5M compile.log | tee compile.log.temp
  29. mv compile.log.temp compile.log
  30. fi