Skip to content

Commit a452915

Browse files
authored
Added snap update and cleanup (#73)
2 parents ee04309 + ceb4555 commit a452915

1 file changed

Lines changed: 17 additions & 30 deletions

File tree

.update.sh

Lines changed: 17 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,23 @@ clean_up() {
121121
esac
122122
}
123123

124-
# Function: os_pkg_update
124+
# Function: update_snapd
125+
# Description: Updates Snap packages if the `snap` command is installed.
126+
update_snapd() {
127+
if ! check_command snap; then
128+
return
129+
fi
130+
131+
if ! snap refresh; then
132+
print_err "Error: Failed to refresh Snap packages."
133+
fi
134+
}
135+
136+
# Function: update_os_pkg
125137
# Description: Updates the system package cache and performs necessary updates based on the detected Linux distribution.
126138
# Supports Debian-based (apt-get), RPM-based (dnf/yum/microdnf), and Alpine (apk) package managers.
127139
# Prints messages indicating the update process and handles errors gracefully.
128-
os_pkg_update() {
140+
update_os_pkg() {
129141
case ${ADJUSTED_ID} in
130142
debian)
131143
if [ "$(find /var/lib/apt/lists/* -maxdepth 1 -check_cmd f 2>/dev/null | wc -l)" -eq 0 ]; then
@@ -138,6 +150,8 @@ os_pkg_update() {
138150
print_err "Error: Update failed."
139151
fi
140152
fi
153+
154+
update_snapd
141155
;;
142156
rhel)
143157
if [ "${PKG_MGR_CMD}" = "microdnf" ]; then
@@ -203,18 +217,6 @@ update_brew() {
203217
brew doctor && brew missing
204218
}
205219

206-
# Function: update_vscode_ext
207-
# Description: Updates Visual Studio Code extensions if VSCode is installed.
208-
update_vscode_ext() {
209-
println "Updating VSCode Extensions"
210-
211-
if ! check_command code; then
212-
return
213-
fi
214-
215-
code --update-extensions
216-
}
217-
218220
# Function: update_gem
219221
# Description: Updates RubyGems if the 'gem' command is installed.
220222
update_gem() {
@@ -251,19 +253,6 @@ update_yarn() {
251253
yarn upgrade --latest
252254
}
253255

254-
# Function: update_pip3
255-
# Description: Updates pip packages if the 'pip3' command is installed.
256-
update_pip3() {
257-
println "Updating Python 3.x pips"
258-
259-
if ! check_command python3 || ! check_command pip3; then
260-
return
261-
fi
262-
263-
# The `--break-system-packages` option is included to bypass the "externally-managed-environment" error
264-
python3 -m pip list --outdated --format=columns | grep -v '^\-e' | cut -d = -f 1 | xargs -n1 python3 -m pip install -U --break-system-packages
265-
}
266-
267256
# Function: update_cargo
268257
# Description: Updates cargo packages if the 'cargo' command is installed.
269258
update_cargo() {
@@ -423,12 +412,10 @@ fi
423412

424413
if check_internet; then
425414
clean_up
426-
os_pkg_update
415+
update_os_pkg
427416
update_brew
428-
update_vscode_ext
429417
update_gem
430418
update_npm
431419
update_yarn
432-
# update_pip3
433420
update_cargo
434421
fi

0 commit comments

Comments
 (0)