diff options
author | Digitalcraftsman <digitalcraftsman@protonmail.com> | 2020-06-10 20:22:08 +0300 |
---|---|---|
committer | Digitalcraftsman <digitalcraftsman@protonmail.com> | 2020-06-12 21:10:46 +0300 |
commit | dc9943156a4400809f8ab737d5568be428a1ca23 (patch) | |
tree | 4ef840bb12b8376a1e35e700b7ee63dbc17247f4 | |
parent | 52c400c1a75a76f5d058b8c20b16975405faafd7 (diff) |
Add shell script for quick theme reviews
-rw-r--r-- | .gitignore | 1 | ||||
-rwxr-xr-x | _script/reviewTheme.sh | 48 |
2 files changed, 49 insertions, 0 deletions
@@ -1,2 +1,3 @@ hugoThemeSite/ _script/*.txt +_script/review diff --git a/_script/reviewTheme.sh b/_script/reviewTheme.sh new file mode 100755 index 0000000..cad25ff --- /dev/null +++ b/_script/reviewTheme.sh @@ -0,0 +1,48 @@ +# /bin/bash + +# exit immediately if one the following commands throws an error +set -e + +function help () { + echo -ne "This script is intended for quick theme reviews. The theme will be cloned into a dedicated directory if not already done. Themes already added to the theme site are ignored, thus total build time decreases. On success, the theme site will be served using the \"hugo server\" command. + +Usage: + +${BASH_SOURCE[0]} URL-TO-GIT-REPOSITORY [arguments] + +Flags: + + -t dedicated directory to clone theme to. Default is $scriptDir/review\n" +} + +repoUrl=$1 +# location of this script +scriptDir=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) +# define location to clone theme to +themesDir="$scriptDir/review" + +if [ $# -eq 0 ]; then + echo -ne "Please provide a url to a Git repository containing the theme as the first argument, e.g. https://github.com/user/theme-name.git\n\n" + help; exit 1 +fi + + +# skip first argument (repoUrl) +OPTIND=2 +while getopts ":t:" opt; do + case $opt in + t) themesDir=$OPTARG;; + *) echo -ne "Unknown argument -$OPTARG provided.\n\n"; help; exit 1;; + esac +done + + +cloneDest="$themesDir/$(basename $repoUrl .git)" +if [ ! -d $cloneDest ]; then + git clone --recursive $repoUrl $cloneDest +fi + +# expose themesDir to generateThemeSite.sh +export HUGO_THEMES_REPO=$themesDir +# generate theme site and start hugo server. +"$scriptDir/generateThemeSite.sh" "http://localhost:1313" && hugo server -w=false -s hugoThemeSite/themeSite |