Last active
November 28, 2023 12:17
-
-
Save atreeon/db5ddeee7b7fedbafd0cc703033bd7f0 to your computer and use it in GitHub Desktop.
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
# updateFlutterVersion 1.23456 | |
function updateFlutterVersion { | |
cd $HOME/installs/flutter | |
CURRENTVERSION=$(git describe --tags) | |
if [ "${CURRENTVERSION}" == "$1" ]; then | |
echo "it looks like you're already on that branch" | |
echo "not changing version" | |
say 'failed' | |
else | |
if [ -d $HOME/installs/flutter_$1 ]; then | |
echo | |
echo "found version '$1' locally, no need to download" | |
echo "Would you like to change Flutter version from '${CURRENTVERSION}' to '$1'?" | |
if ! asksure; then | |
return | |
fi | |
cd .. | |
mv $HOME/installs/flutter $HOME/installs/flutter_${CURRENTVERSION} | |
mv $HOME/installs/flutter_$1 $HOME/installs/flutter | |
echo | |
say 'success' | |
echo 'flutter updated' | |
else | |
CURRENTVERSION=$(git describe --tags) | |
echo "version not found locally" | |
if [ ! $(git tag -l "$1") ]; then | |
echo "Flutter version '$1' not found in git, would you like to pull the latest from git?" | |
if ! asksure; then | |
return | |
fi | |
git pull | |
fi | |
if [ $(git tag -l "$1") ]; then | |
echo "Flutter version '$1' found in git" | |
echo "Would you like to change Flutter version from '${CURRENTVERSION}' to '$1'?" | |
if ! asksure; then | |
return | |
fi | |
echo "Would you like to save a copy of Flutter version from '${CURRENTVERSION}'? It may use up 20gb of data and take a few minutes to copy the data" | |
if asksure; then | |
cp -R $HOME/installs/flutter $HOME/installs/flutter_${CURRENTVERSION} | |
fi | |
git checkout $1 | |
flutter doctor | |
flutter precache | |
echo | |
echo | |
df -k . | |
echo | |
say 'success' | |
echo 'flutter updated' | |
else | |
say 'failed' | |
echo "couldn't find Flutter version '$1' in git" | |
fi | |
fi | |
fi | |
echo | |
echo | |
echo | |
flutter --version | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment