diff --git a/setup-profiles.bash b/setup-profiles.bash index ce85d0b..c39635b 100755 --- a/setup-profiles.bash +++ b/setup-profiles.bash @@ -4,13 +4,15 @@ BASEDIR=$(cd "$(dirname "$0")" && pwd) echo "BASEDIR=$BASEDIR" -# Prerequisite check for yq -if ! command -v yq &> /dev/null -then - echo "Error: yq is not installed." - echo "Please install yq to use this script. Refer to https://github.com/mikefarah/yq#install for installation methods." - exit 1 -fi +check_prerequisites() { + # Prerequisite check for yq + if ! command -v yq &> /dev/null + then + echo "Error: yq is not installed." + echo "Please install yq to use this script. Refer to https://github.com/mikefarah/yq#install for installation methods." + exit 1 + fi +} update_profile() { local profile_file="$1" @@ -35,6 +37,8 @@ update_profile() { cd "$BASEDIR" || exit +check_prerequisites + if [ "$#" -eq 0 ]; then # No arguments, update all profiles echo "No profile specified, updating all profiles..." @@ -50,4 +54,4 @@ else echo "Error: Profile file '$file_path' not found. Skipping." fi done -fi +fi \ No newline at end of file