Last active
May 16, 2022 03:26
-
-
Save chnirt/4b83eb6766aaac3b324a3ef58735de8c to your computer and use it in GitHub Desktop.
Switch version
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 | |
echo "Switch version by Chnirt"; | |
# * node v16.14.2 | |
# * ruby 3.1.2 | |
# * cocoapod 1.11.3 | |
node_version_default=16.14.2 | |
ruby_version_default=3.1.2 | |
cocoapod_version_default=1.11.3 | |
while [ -z $node_version ]; do | |
read -p "Node version ($node_version_default):" node_version | |
node_version=${node_version:-$node_version_default} | |
done | |
while [ -z $ruby_version ]; do | |
read -p "Ruby version ($ruby_version_default):" ruby_version | |
ruby_version=${ruby_version:-$ruby_version_default} | |
done | |
while [ -z $cocoapod_version ]; do | |
read -p "Cocoapod version ($cocoapod_version_default):" cocoapod_version | |
cocoapod_version=${cocoapod_version:-$cocoapod_version_default} | |
done | |
# check node | |
if which node > /dev/null | |
then | |
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash | |
export NVM_DIR=~/.nvm | |
source ~/.nvm/nvm.sh | |
echo "Node is installed, skipping..." | |
nvm install $node_version | |
nvm alias default $node_version | |
nvm use $node_version | |
else | |
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash | |
export NVM_DIR=~/.nvm | |
source ~/.nvm/nvm.sh | |
echo "Install node" | |
nvm install $node_version | |
nvm alias default $node_version | |
nvm use $node_version | |
fi | |
# check rvm | |
if which rvm > /dev/null | |
then | |
echo "Rvm is installed, skipping..." | |
source ~/.rvm/scripts/rvm | |
rvm reinstall $ruby_version | |
rvm --default use $ruby_version | |
else | |
echo "Install rvm" | |
curl -sSL https://get.rvm.io | bash | |
source ~/.rvm/scripts/rvm | |
rvm reinstall $ruby_version | |
rvm --default use $ruby_version | |
fi | |
# check cocoapod | |
yes | gem uninstall cocoapods | |
gem install -n /usr/local/bin cocoapods -v $cocoapod_version | |
pod _"$cocoapod_version"_ setup | |
echo "Completed" | |
# === done === | |
# # bash <(curl -Ls https://gist.githubusercontent.com/xxx/switch-version.sh) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment