vue-builds.sh 947 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #!/bin/bash
  2. root=$(pwd)
  3. entryFile=$1
  4. if [ ! -f "$entryFile" ]
  5. then
  6. echo "The build file $entryFile does not exists"
  7. exit 2
  8. else
  9. path=$(dirname "$entryFile")
  10. file=$(basename $entryFile)
  11. set -e
  12. cd $path
  13. echo "Entering $path"
  14. # support for multiple chunks
  15. for chunk in *$file; do
  16. # Backup original file
  17. backupFile="$chunk.orig"
  18. echo "Backing up $chunk to $backupFile"
  19. cp $chunk $backupFile
  20. done
  21. # Make the app
  22. echo "Making $file"
  23. cd ../
  24. npm --silent install
  25. npm run --silent build
  26. # Reset
  27. cd $root
  28. cd $path
  29. # support for multiple chunks
  30. for chunk in *$file; do
  31. # Compare build files
  32. echo "Comparing $chunk to the original"
  33. backupFile="$chunk.orig"
  34. if ! diff -q $chunk $backupFile &>/dev/null
  35. then
  36. echo "$chunk build is NOT up-to-date! Please send the proper production build within the pull request"
  37. cat $HOME/.npm/_logs/*.log
  38. exit 2
  39. else
  40. echo "$chunk build is up-to-date"
  41. fi
  42. done
  43. fi