-
Notifications
You must be signed in to change notification settings - Fork 3
/
init-asdf.sh
executable file
·54 lines (47 loc) · 1.19 KB
/
init-asdf.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/env bash
set -eu
if ! command -v asdf &>/dev/null; then
echo "❌ asdf not found on PATH"
echo "💡 Install asdf: https://asdf-vm.com/guide/getting-started.html"
if [[ "$OSTYPE" == "darwin"* ]]; then
echo
echo "brew install asdf"
echo
echo "Note: you still need to set up shell integration per the above docs"
fi
exit 1
else
echo "✅ asdf is installed"
fi
echo "🛠 Installing required asdf plugins..."
install_asdf_plugin() {
local PLUGIN_NAME="$1"
local PLUGIN_URL="${2:-}"
if ! asdf plugin list | grep -q "$PLUGIN_NAME"; then
echo "🛠 Installing plugin $PLUGIN_NAME..."
if [ -z "$PLUGIN_URL" ]; then
asdf plugin add "$PLUGIN_NAME"
else
asdf plugin add "$PLUGIN_NAME" "$PLUGIN_URL"
fi
echo "✅ Plugin $PLUGIN_NAME has been installed."
else
echo "✅ Plugin $PLUGIN_NAME is already installed."
fi
}
install_asdf_plugin flutter
install_asdf_plugin jq
echo "🛠 Running asdf install..."
set +e
asdf install
EXIT_STATUS=$?
set -e
if [[ $EXIT_STATUS -ne 0 ]]; then
echo "❌ asdf install was not successful"
exit 1
else
echo "✅ asdf install ran successfully."
fi
asdf reshim
echo
echo "✨ asdf is ready to use."