Guest User

Untitled

a guest
Dec 15th, 2018
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.96 KB | None | 0 0
  1. #!/usr/bin/env bash
  2.  
  3. info () {
  4. printf "\r [ \033[00;34m..\033[0m ] $1\n"
  5. }
  6.  
  7. success () {
  8. printf "\r\033[2K [ \033[00;32mOK\033[0m ] $1\n"
  9. }
  10.  
  11. fail () {
  12. printf "\r\033[2K [\033[0;31mFAIL\033[0m] $1\n"
  13. echo ''
  14. exit
  15. }
  16.  
  17. LOG_FILE="$(pwd)/nuke-it.log"
  18. # remove log file if already exists
  19. [[ ! -e "$LOG_FILE" ]] || rm "$LOG_FILE"
  20.  
  21. # everyone loves a mushroom cloud ;)
  22. if hash base64 2>/dev/null && hash gunzip 2>/dev/null; then
  23. base64 --decode <<<"H4sIAJQcFFwAA11NQQrDMAy7+xW6NYHiPKAv2B8CTgeBHsYKbcbopW+fHRraTrYSI0UO0CBgsbOvEzXZCTo4JMCrzSL+sJyWtRrK5O1uphOxYE2zqtb9GbX3+56ibmYEG0+jYjD+aUEZSa4IAv0o3jSy2KN0K8qUMb9fG77jhjLjmbF+lsxE9APlrOhe9gAAAA==" | gunzip
  24. fi
  25.  
  26. # watchman is required for RN.
  27. # even still, check before run.
  28. if hash watchman 2>/dev/null; then
  29. info "removing all watchman watches"
  30. watchman watch-del-all >> "$LOG_FILE"
  31. fi
  32.  
  33. info "removing cache and build directories"
  34. info "> removing Xcode derived data"
  35. rm -rf ~/Library/Developer/Xcode/DerivedData
  36. info "> removing CocoaPods download cache"
  37. rm -rf ~/Library/Caches/CocoaPods
  38. info "> removing node_modules"
  39. rm -rf node_modules
  40. info "> removing ios build artifacts"
  41. rm -rf ios/build
  42. info "> removing cocoapods artifacts"
  43. rm -rf ios/Pods
  44. info "> removing RN artifacts in $TMPDIR"
  45. rm -rf $TMPDIR/react-*
  46.  
  47. info "check for package manager"
  48. if hash yarn 2>/dev/null; then
  49. info "> using yarn, installing dependencies ..."
  50. yarn >> "$LOG_FILE"
  51. elif hash npm 2>/dev/null; then
  52. info "> using npm, installing dependencies ..."
  53. npm install >> "$LOG_FILE"
  54. else
  55. fail "package manager not found. install dependencies manually."
  56. fi
  57.  
  58. info "check for pod executable"
  59. if hash pod 2>/dev/null; then
  60. info "> pod exe found. installing pods ..."
  61. cd ios
  62.  
  63. if ! pod install >> "$LOG_FILE" 2>&1; then
  64. fail "> failed to install cocoa pods. check log for errors."
  65. fi
  66.  
  67. cd ..
  68. else
  69. fail "> pod executable not found. install pods manually."
  70. fi
  71.  
  72. success "nuked the project. all build artifacts have been removed."
Add Comment
Please, Sign In to add comment