Last active
September 9, 2024 12:33
-
-
Save Mastersam07/1568d12666fc4581c0f425c723c3472a to your computer and use it in GitHub Desktop.
A script to clean all flutter projects on your machine
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Directories to exclude | |
EXCLUDE_DIRS=( | |
"/System" | |
"/Library" | |
"/Applications" | |
"/Volumes" | |
"/opt/homebrew" | |
"/opt/homebrew/bin/fvm" | |
"/Users/codefarmer/fvm" | |
"/Users/codefarmer/development" | |
"/Users/codefarmer/.pub-cache" | |
"$HOME/.vscode/extensions" | |
"$HOME/.vscode-insiders/extensions" | |
"/Users/codefarmer/.cursor/extensions" | |
"/Users/codefarmer/.shorebird" | |
"/Users/codefarmer/.mason-cache" | |
) | |
# Convert EXCLUDE_DIRS array into a find exclude format | |
EXCLUDE_PARAMS="" | |
for dir in "${EXCLUDE_DIRS[@]}"; do | |
EXCLUDE_PARAMS="$EXCLUDE_PARAMS -path $dir -prune -o" | |
done | |
# Find all Flutter projects by looking for pubspec.yaml files, excluding specified directories | |
echo "Searching for Flutter projects across your Mac, excluding: ${EXCLUDE_DIRS[*]}..." | |
eval "find / $EXCLUDE_PARAMS -name 'pubspec.yaml' -print 2>/dev/null" | while read -r pubspec; do | |
# Get the directory of the Flutter project | |
project_dir=$(dirname "$pubspec") | |
# Move to the project directory | |
cd "$project_dir" | |
# Clean the Flutter project | |
echo "Cleaning Flutter project in $project_dir..." | |
flutter clean | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment