From 26f8a1b906c329fa92adc2480e1769b8a90347de Mon Sep 17 00:00:00 2001 From: q-posev Date: Thu, 28 Jul 2022 12:02:18 +0200 Subject: [PATCH] Adapt htmlize installer for the case of existing git submodule --- tools/install_htmlize.sh | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/tools/install_htmlize.sh b/tools/install_htmlize.sh index b1f52d7..c778103 100755 --- a/tools/install_htmlize.sh +++ b/tools/install_htmlize.sh @@ -2,8 +2,25 @@ # # Installs the htmlize Emacs plugin -${abs_srcdir}/tools/missing git clone "https://github.com/TREX-CoE/emacs-htmlize" -mv emacs-htmlize/htmlize.el $1 -rm -rf emacs-htmlize +readonly HTMLIZE_EL=$1 +# If the file already present - exit the script +if [ -f ${HTMLIZE_EL} ] +then + exit 0 +fi + +DOC_ROOT=${HTMLIZE_EL%/*} +readonly EMACS_HTMLIZE=${DOC_ROOT}/emacs-htmlize/htmlize.el + +# Case 1: submodule cloned but htmlize.el is absent in DOC_ROOT +if [ -f ${EMACS_HTMLIZE} ] +then + cp ${EMACS_HTMLIZE} ${HTMLIZE_EL} +else +# Case 2: submodule has not been cloned + ${abs_srcdir}/tools/missing git clone "https://github.com/TREX-CoE/emacs-htmlize" + mv emacs-htmlize/htmlize.el ${HTMLIZE_EL} + rm -rf emacs-htmlize +fi