This commit is contained in:
pika 2025-05-24 01:10:34 +02:00
parent 8791de659c
commit ef04287336

View file

@ -122,15 +122,36 @@ run-silent() {
# if given an array, it checks if the command is available, and if not - installs all packages in that array one by one # if given an array, it checks if the command is available, and if not - installs all packages in that array one by one
check-and-install() { check-and-install() {
local pkg=$1 # local pkg=$1
# echo "DEBUG:: GOT ARRAY :: ${@}" # echo "DEBUG:: GOT ARRAY :: ${@}"
# INFO: if it's not a list, then just check and install the package.. # INFO: if it's not a list, then just check and install the package..
if [[ -z $2 ]]; then #
spin bold yellow "Installing $pkg" # if [[ -z $2 ]]; then
if ! command-exists "$pkg"; then # spin bold yellow "Installing $pkg"
if run --err err pkg-install "$pkg"; then # if ! command-exists "$pkg"; then
# if run --err err pkg-install "$pkg"; then
# upclear
# check bold "$(pen green bold 'Installed') $pkg"
# else
# upclear
# throw "Something went wrong! Could not install $(pen bold red $pkg)"
# echo-error "${err:-}"
# fi
# else
# upclear
# check bold "$pkg $(pen grey bold 'was already installed')"
# # echo_pkg deps "skipping $pkg - as it's ${RED}already installed.."
# fi
# else
local pkglength="${#@}"
# ─< else go though the list of items and do the same >───────────────────────────────────
pen grey "Packages to install: $(pen green bold $pkglength)"
for pkg in "$@"; do
if ! command-exists $pkg; then
spin bold "$(pen bold yellow Installing) $pkg"
if run --err err pkg-install $pkg; then
upclear upclear
check bold "$(pen green bold 'Installed') $pkg" check "$(pen bold green Installed) $pkg"
else else
upclear upclear
throw "Something went wrong! Could not install $(pen bold red $pkg)" throw "Something went wrong! Could not install $(pen bold red $pkg)"
@ -139,29 +160,9 @@ check-and-install() {
else else
upclear upclear
check bold "$pkg $(pen grey bold 'was already installed')" check bold "$pkg $(pen grey bold 'was already installed')"
# echo_pkg deps "skipping $pkg - as it's ${RED}already installed.."
fi fi
else done
local pkglength="${#@}" # fi
# ─< else go though the list of items and do the same >───────────────────────────────────
pen grey "Packages to install: $(pen green bold $pkglength)"
for pkg in "$@"; do
if ! command-exists $pkg; then
spin bold "$(pen bold yellow Installing) $pkg"
if run --err err pkg-install $pkg; then
upclear
check "$(pen bold green Installed) $pkg"
else
upclear
throw "Something went wrong! Could not install $(pen bold red $pkg)"
echo-error "${err:-}"
fi
else
upclear
check bold "$pkg $(pen grey bold 'was already installed')"
fi
done
fi
} }
# ─< Check if the user is root and set sudo variable if necessary >─────────────────────── # ─< Check if the user is root and set sudo variable if necessary >───────────────────────