Spinner prints "ok" on failure
The new apply.sh looks really awesome!
One downside: when one of the initializations fails, it still prints ok and continues the initialization.
I'd prefer if it printed failed and stops the execution.
You can reproduce this by making an init function return 1 for example.
You're right, it would be much better.
The current implementation is more of a workaround so that the spinner won't stop at a random character at the end of its spinning lifecycle:
[ / ] placeholder text [ - ] placeholder text [ / ] placeholder text [ \ ] placeholder text
So the [ ok ] is hard coded right now.
Any ideas?
I tried adding the following to the end of spinner() but it doesn't work reliably, probably because the function is not allowed to wait for the process.
set -x
echo waiting
wait $!
return_code=$?
if [ $return_code -eq 0 ]; then
echo -e "[\e[32mok\e[0m] $info"
else
echo -e "[\e[31mfailed\e[0m] $info"
fi
set +x
It could be a solution to only pass the command to be executed to the spinner and make it start the background process. This way, it probably would be allowed to access the process and wait for it.
Not sure if this will work. Maybe we can look into it at the of the sprint :wink:
Yeah, let's look into it at the end of the sprint :). So far I didn't think about a solution to this problem.
While we're on it we could also add a debug param or env var to spinner, so we don't have to repeat all commands. Keeping our apply.sh more DRY :slightly_smiling_face: