-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathinstall_dev_requirement.sh
executable file
·77 lines (69 loc) · 1.4 KB
/
install_dev_requirement.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/bin/bash
# install development requirements
lists=(
"git"
"upx"
"dpkg"
"gh"
"wget"
"gofumpt"
"just"
"prettier"
"choose-rust"
"ripgrep"
"golangci-lint"
)
command=(
"git"
"upx"
"dpkg"
"gh"
"wget"
"gofumpt"
"just"
"prettier"
"choose"
"rg"
"golangci-lint"
)
# load base.sh
source "$(dirname "$0")/base.sh"
# check if brew is installed
if ! command -v brew &> /dev/null; then
error "brew is not installed"
exit 1
fi
echo "brew update"
brew update > /dev/null
if [ $? -ne 0 ]; then
error "brew update failed"
fi
if ! command -v go &> /dev/null; then
echo "brew install go"
brew install go
else # check go version >= 1.21.0
go_version=$(go version | awk '{print $3}')
go_version=${go_version:2}
if [ "$(printf '%s\n' "1.21.0" "$go_version" | sort -V | head -n1)" != "1.21.0" ]; then
# check if go is installed by brew
if brew list --versions go &> /dev/null; then
echo "brew upgrade go"
brew upgrade go
else
echo "please upgrade go to 1.21.0 or later"
fi
fi
fi
for i in "${!lists[@]}"; do
if ! command -v "${command[i]}" &> /dev/null; then
echo "brew install ${lists[i]}..."
HOMEBREW_NO_AUTO_UPDATE=1 brew install "${lists[i]}" > /dev/null
if [ $? -ne 0 ]; then
error "brew install ${lists[i]} failed"
else
success "${lists[i]} installed"
fi
else
success "${lists[i]} already installed"
fi
done