Skip to content

Commit

Permalink
[#3664] Fix site build scripts
Browse files Browse the repository at this point in the history
Removed deprecated -v flag.
Also added options for specifying Hugo executable and target directory
to Unix site build script.
  • Loading branch information
sophokles73 committed Nov 28, 2024
1 parent 453d971 commit 1f702fd
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 19 deletions.
10 changes: 5 additions & 5 deletions site/build-site.bat
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@rem ***************************************************************************
@rem Copyright (c) 2016, 2022 Contributors to the Eclipse Foundation
@rem Copyright (c) 2016 Contributors to the Eclipse Foundation
@rem
@rem See the NOTICE file(s) distributed with this work for additional
@rem information regarding copyright ownership.
Expand Down Expand Up @@ -30,19 +30,19 @@ IF ERRORLEVEL 1 (
cd homepage
IF NOT "%~1"=="" (
ECHO Going to build homepage in directory: %1
hugo -v -d %1
hugo -d %1
) ELSE (
ECHO Going to build homepage in default directory...
hugo -v
hugo
)
cd ..

cd documentation
IF NOT "%~1"=="" (
ECHO Going to build documentation in directory: %1\docs
hugo -v -d %1\docs
hugo -d %1\docs
) ELSE (
ECHO Going to build documentation in default directory...
hugo -v
hugo
)
cd ..
62 changes: 48 additions & 14 deletions site/build-site.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash
#*******************************************************************************
# Copyright (c) 2016, 2022 Contributors to the Eclipse Foundation
# Copyright (c) 2016 Contributors to the Eclipse Foundation
#
# See the NOTICE file(s) distributed with this work for additional
# information regarding copyright ownership.
Expand All @@ -12,30 +12,64 @@
# SPDX-License-Identifier: EPL-2.0
#*******************************************************************************

target="public"
hugo_cmd="hugo"

if ! hugo version; then
echo "Please install \"hugo\" to be able to build the hono documentation. See readme.md for further details."
exit 0
fi
print_usage() {
cmd_name=$(basename "$0")
cat <<EOF >&2
Usage: ${cmd_name} OPTIONS ...
OPTIONS
-h | --help Display this usage information.
-H | --hugo The path to the Hugo executable to use for building the site. [$hugo_cmd]
-t | --target PATH The path to the folder to contain the site. [$target]
if [ "$1" ]
EOF
}

while [[ "$1" =~ ^- && ! "$1" == "--" ]]; do case $1 in
-h | --help )
print_usage
exit 1
;;
-H | --hugo )
shift; hugo_cmd=$1
;;
-t | --target )
shift; target=$1
;;
*)
echo "Ignoring unknown option: $1"
echo "Run with flag -h for usage"
;;
esac; shift; done
if [[ "$1" == '--' ]]; then shift; fi

hugo_version=$($hugo_cmd version)
if [[ -z "$hugo_version" ]]
then
TARGET="$1"
else
TARGET="public"
echo "Could not find \"$hugo_cmd\" executable on your PATH. See readme.md for further details."
exit 0
fi

if ! git submodule status; then
submodule_status=$(git submodule status)
if [[ -z "$submodule_status" ]]
then
echo "Initializing submodules containing Hugo themes."
git submodule update --init
echo
fi

cd homepage || exit
echo "Building homepage in directory: $TARGET"
hugo -v -d $TARGET
echo "Building homepage in directory: $target"
$hugo_cmd -d $target
echo
echo
cd ..

cd documentation || exit
echo "Building documentation in directory: $TARGET/docs"
hugo -v -d $TARGET/docs
echo "Building documentation in directory: $target/docs"
$hugo_cmd -d $target/docs
cd ..

0 comments on commit 1f702fd

Please sign in to comment.