Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
abraaolevi committed Oct 2, 2020
2 parents ea92094 + c23dd05 commit 3bf2d30
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
25 changes: 17 additions & 8 deletions cleanup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand All @@ -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...'
Expand All @@ -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
Expand Down

0 comments on commit 3bf2d30

Please sign in to comment.