diff --git a/README.md b/README.md index 8da7e1a..8a94016 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,6 @@ A cleanup script for macOS that runs the following tasks: * Cleanup Yarn Cache * Cleanup Docker Images and Stopped Containers * Cleanup CocoaPods Cache Files -* Cleanup Google Chrome Cache Files * Cleanup composer cache * Cleanup Dropbox cache diff --git a/cleanup.sh b/cleanup.sh index 5b88dd6..0f9bd93 100755 --- a/cleanup.sh +++ b/cleanup.sh @@ -10,6 +10,20 @@ bytesToHuman() { echo "$b$d ${S[$s]} of space was cleaned up" } +deleteCaches() { + local cacheName=$1 + shift + local paths=("$@") + echo "Initiating cleanup ${cacheName} cache..." + for folderPath in "${paths[@]}"; do + if [[ -d ${folderPath} ]]; then + dirSize=$(du -hs "${folderPath}" | awk '{print $1}') + echo "Deleting ${folderPath} to free up ${dirSize}..." + rm -rfv "${folderPath}" &>/dev/null + fi + done +} + # Default arguments doUpdates=true @@ -71,6 +85,7 @@ if type "xcrun" &>/dev/null; then osascript -e 'tell application "com.apple.CoreSimulator.CoreSimulatorService" to quit' osascript -e 'tell application "iOS Simulator" to quit' osascript -e 'tell application "Simulator" to quit' + xcrun simctl shutdown all xcrun simctl erase all fi @@ -79,12 +94,6 @@ if [ -d "/Users/${HOST}/Library/Caches/CocoaPods" ]; then rm -rfv ~/Library/Caches/CocoaPods/* &>/dev/null fi -# support delete Google Chrome caches -if [ -d "/Users/${HOST}/Library/Caches/Google/Chrome" ]; then - echo 'Cleanup Google Chrome cache...' - rm -rfv ~/Library/Caches/Google/Chrome/* &> /dev/null -fi - # support delete gradle caches if [ -d "/Users/${HOST}/.gradle/caches" ]; then echo 'Cleanup Gradle cache...' @@ -93,8 +102,8 @@ fi # support delete Dropbox Cache if [ -d "/Users/${HOST}/Dropbox" ]; then -echo 'Clear Dropbox 📦 Cache Files...' -sudo rm -rfv ~/Dropbox/.dropbox.cache/* &>/dev/null + echo 'Clear Dropbox 📦 Cache Files...' + sudo rm -rfv ~/Dropbox/.dropbox.cache/* &>/dev/null fi if type "composer" &> /dev/null; then