Skip to content

Commit 3dbfb86

Browse files
committed
Upgrade pkgm too
1 parent c3a546f commit 3dbfb86

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

installer.sh

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ _main() {
77
_install_pkgx "$@"
88
_install_pre_reqs
99
elif [ $# -eq 0 ]; then
10-
echo "$(pkgx --version) already installed" >&2
10+
echo /usr/local/bin/"$(pkgx --version) already installed" >&2
11+
echo /usr/local/bin/"$(pkgm --version) already installed" >&2
1112
exit
1213
fi
1314

@@ -121,9 +122,9 @@ _install_pkgx() {
121122

122123
if [ $# -eq 0 ]; then
123124
if [ -f /usr/local/bin/pkgx ]; then
124-
echo "upgrading: /usr/local/bin/pkgx" >&2
125+
echo "upgrading: /usr/local/bin/pkg[xm]" >&2
125126
else
126-
echo "installing: /usr/local/bin/pkgx" >&2
127+
echo "installing: /usr/local/bin/pkg[xm]" >&2
127128
fi
128129

129130
# using a named pipe to prevent curl progress output trumping the sudo password prompt
@@ -150,6 +151,7 @@ _install_pkgx() {
150151

151152
# tell the user what version we just installed
152153
pkgx --version
154+
pkgm --version
153155

154156
else
155157
curl $progress --fail --proto '=https' \
@@ -176,10 +178,22 @@ _pkgx_is_old() {
176178
fi
177179
}
178180

181+
_pkgm_is_old() {
182+
if [ "$PKGX_UPDATE" = no ]; then
183+
return 1
184+
else
185+
new_version=$(curl -Ssf https://pkgxdev.github.io/pkgm/version.txt)
186+
old_version=$(pkgm --version || echo pkgm 0)
187+
old_version=$(echo $old_version | cut -d' ' -f2)
188+
189+
/usr/local/bin/pkgx --silent semverator gt $new_version $old_version
190+
fi
191+
}
192+
179193
_should_install_pkgx() {
180194
if [ ! -f /usr/local/bin/pkgx ]; then
181195
return 0
182-
elif _pkgx_is_old >/dev/null 2>&1; then
196+
elif _pkgx_is_old >/dev/null 2>&1 || _pkgm_is_old >/dev/null 2>&1; then
183197
return 0
184198
else
185199
return 1

0 commit comments

Comments
 (0)