Skip to content

Commit

Permalink
feat: Building Hugo site
Browse files Browse the repository at this point in the history
  • Loading branch information
UmmItC committed May 31, 2024
1 parent f1e178d commit 2790914
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,23 @@ GRAY='\033[1;30m'
DARKRED='\033[0;31m'
NC='\033[0m' # No Color

# Function for Hugo building
build_hugo() {
echo -e "${GREEN}[+] Building Hugo site...${NC}"
hugo --minify
echo -e "${GREEN}[+] Hugo build complete.${NC}"
}

valid_choice=false
do_hugo=false

while [ "$valid_choice" == false ]; do
# Check if --noconfirm is passed as a command-line argument
if [[ "$@" == *"--noconfirm"* ]]; then
choice="y"
else
# Prompt user for confirmation
read -p "Do you want to update submodules? [Y/n]: " choice
read -p "Do you want to update Hugo site and submodules? [Y/n]: " choice
choice=${choice:-y} # Default to 'yes' if user just presses Enter
fi

Expand All @@ -23,15 +31,21 @@ while [ "$valid_choice" == false ]; do
# Update submodules recursively
echo -e "${GREEN}[+] Updating submodules...${NC}"
git submodule update --init --recursive --remote
echo -e "${GREEN}[+] Updated complete.${NC}"
echo -e "${GREEN}[+] Updated submodules complete.${NC}"
valid_choice=true
do_hugo=true
;;
n|N )
echo -e "${GRAY}[~] No submodule update performed.${NC}"
echo -e "${GRAY}[~] No update performed.${NC}"
valid_choice=true
;;
* )
echo -e "${DARKRED}[!] Invalid choice, please choose 'y' or 'n'.${NC}"
;;
esac
done

# Build Hugo site after updating submodules if --hugo option is provided
if [ "$do_hugo" = true ]; then
build_hugo
fi

0 comments on commit 2790914

Please sign in to comment.