From ae01546c0a71abb16549d57cd3e0208dbc3a781d Mon Sep 17 00:00:00 2001 From: Xavier Logerais Date: Sun, 13 Jul 2025 00:06:13 +0200 Subject: [PATCH] feat: Enhance setup-profiles.bash Move pre-requisites check in a separate function --- setup-profiles.bash | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) 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