Skip to content

Commit 1607be1

Browse files
committed
install.sh fixes
1 parent ea87b60 commit 1607be1

File tree

1 file changed

+41
-7
lines changed

1 file changed

+41
-7
lines changed

Diff for: install.sh

+41-7
Original file line numberDiff line numberDiff line change
@@ -48,28 +48,62 @@ catch() {
4848
fi
4949
}
5050

51+
# spinner() {
52+
# pid=$1
53+
# spin='-\|/'
54+
# i=0
55+
56+
# while kill -0 $pid 2>/dev/null; do
57+
# i=$(((i + 1) % 4))
58+
59+
# # If we are in a github actions workflow, we don't want to print the spinner
60+
# if [ "$GITHUB_ACTIONS" != "true" ]; then
61+
# printf "\r${spin:$i:1}"
62+
# fi
63+
64+
# sleep .1
65+
# done
66+
67+
# # If we are in a github actions workflow, we don't want to print this return line
68+
# if [ "$GITHUB_ACTIONS" != "true" ]; then
69+
# printf "\r"
70+
# fi
71+
# }
72+
5173
spinner() {
52-
pid=$1
74+
arg="$1"
5375
spin='-\|/'
5476
i=0
5577

56-
while kill -0 $pid 2>/dev/null; do
57-
i=$(((i + 1) % 4))
78+
check_condition() {
79+
if [[ "$arg" =~ ^[0-9]+$ ]]; then
80+
# Numeric: assume it's a PID
81+
! kill -0 "$arg" 2>/dev/null
82+
elif [[ "$arg" == /* ]]; then
83+
# Starts with /: assume it's a file path
84+
[ -e "$arg" ]
85+
else
86+
# Otherwise: check if command is in PATH
87+
command -v "$arg" >/dev/null 2>&1
88+
fi
89+
}
5890

59-
# If we are in a github actions workflow, we don't want to print the spinner
91+
while ! check_condition; do
92+
i=$(( (i + 1) % 4 ))
93+
# If we are in a GitHub Actions workflow, we don't want to print the spinner
6094
if [ "$GITHUB_ACTIONS" != "true" ]; then
6195
printf "\r${spin:$i:1}"
6296
fi
63-
6497
sleep .1
6598
done
6699

67-
# If we are in a github actions workflow, we don't want to print this return line
100+
# If we are in a GitHub Actions workflow, we don't want to print this return line
68101
if [ "$GITHUB_ACTIONS" != "true" ]; then
69102
printf "\r"
70103
fi
71104
}
72105

106+
73107
#################
74108
### FUNCTIONS ###
75109
#################
@@ -273,7 +307,7 @@ install_froster() {
273307
echo " Installing from the current directory"
274308
echo -e "\nInstalling Froster from the current directory in --editable mode..."
275309
python3 -m pip install --force -e . >/dev/null 2>&1 & #>/dev/null 2>&1
276-
spinner $!
310+
spinner "froster"
277311
sleep 3
278312
if ! [[ -f "${HOME}/.local/bin/froster" ]]; then
279313
echo "${HOME}/.local/bin/froster not available, exiting."

0 commit comments

Comments
 (0)