Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env bash
- info () {
- printf "\r [ \033[00;34m..\033[0m ] $1\n"
- }
- success () {
- printf "\r\033[2K [ \033[00;32mOK\033[0m ] $1\n"
- }
- fail () {
- printf "\r\033[2K [\033[0;31mFAIL\033[0m] $1\n"
- echo ''
- exit
- }
- LOG_FILE="$(pwd)/nuke-it.log"
- # remove log file if already exists
- [[ ! -e "$LOG_FILE" ]] || rm "$LOG_FILE"
- # everyone loves a mushroom cloud ;)
- if hash base64 2>/dev/null && hash gunzip 2>/dev/null; then
- base64 --decode <<<"H4sIAJQcFFwAA11NQQrDMAy7+xW6NYHiPKAv2B8CTgeBHsYKbcbopW+fHRraTrYSI0UO0CBgsbOvEzXZCTo4JMCrzSL+sJyWtRrK5O1uphOxYE2zqtb9GbX3+56ibmYEG0+jYjD+aUEZSa4IAv0o3jSy2KN0K8qUMb9fG77jhjLjmbF+lsxE9APlrOhe9gAAAA==" | gunzip
- fi
- # watchman is required for RN.
- # even still, check before run.
- if hash watchman 2>/dev/null; then
- info "removing all watchman watches"
- watchman watch-del-all >> "$LOG_FILE"
- fi
- info "removing cache and build directories"
- info "> removing Xcode derived data"
- rm -rf ~/Library/Developer/Xcode/DerivedData
- info "> removing CocoaPods download cache"
- rm -rf ~/Library/Caches/CocoaPods
- info "> removing node_modules"
- rm -rf node_modules
- info "> removing ios build artifacts"
- rm -rf ios/build
- info "> removing cocoapods artifacts"
- rm -rf ios/Pods
- info "> removing RN artifacts in $TMPDIR"
- rm -rf $TMPDIR/react-*
- info "check for package manager"
- if hash yarn 2>/dev/null; then
- info "> using yarn, installing dependencies ..."
- yarn >> "$LOG_FILE"
- elif hash npm 2>/dev/null; then
- info "> using npm, installing dependencies ..."
- npm install >> "$LOG_FILE"
- else
- fail "package manager not found. install dependencies manually."
- fi
- info "check for pod executable"
- if hash pod 2>/dev/null; then
- info "> pod exe found. installing pods ..."
- cd ios
- if ! pod install >> "$LOG_FILE" 2>&1; then
- fail "> failed to install cocoa pods. check log for errors."
- fi
- cd ..
- else
- fail "> pod executable not found. install pods manually."
- fi
- success "nuked the project. all build artifacts have been removed."
Add Comment
Please, Sign In to add comment