Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/gohugoio/hugoThemes.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDigitalcraftsman <digitalcraftsman@protonmail.com>2020-06-10 20:22:08 +0300
committerDigitalcraftsman <digitalcraftsman@protonmail.com>2020-06-12 21:10:46 +0300
commitdc9943156a4400809f8ab737d5568be428a1ca23 (patch)
tree4ef840bb12b8376a1e35e700b7ee63dbc17247f4
parent52c400c1a75a76f5d058b8c20b16975405faafd7 (diff)
Add shell script for quick theme reviews
-rw-r--r--.gitignore1
-rwxr-xr-x_script/reviewTheme.sh48
2 files changed, 49 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
index dab53ba..8435c5a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -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