Skip to content

Commit 0217c5d

Browse files
committed
Add generated source files cleaning after script
1 parent c2ec00f commit 0217c5d

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

script/start.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,14 @@ if [ "$MODE" = "HTML" -o "$MODE" = "html" -o "$MODE" = "gh-pages" ] ; then
3030
if [ ! -f "${TOC}" ] ; then
3131
echo "TOC file (contents.md) not found. It will be created using a script..."
3232
(cd "${SRC}" ; python /usr/local/src/toc.py "${TOC}")
33+
CLEAN_TOC=true
3334
fi
3435

3536
# Index is the entrypoint of every website so it's mandatory
3637
if [ ! -f "${SRC}/index.md" ] ; then
3738
echo "Index file (index.md) not found. It will be created using a script..."
3839
echo "# ${GITHUB_REPOSITORY:-Documentation}" > "${SRC}/index.md"
40+
CLEAN_INDEX=true
3941
fi
4042

4143
# Styling should be provided inside a "css" folder but the default, base style file should be called style.css.
@@ -44,6 +46,7 @@ if [ "$MODE" = "HTML" -o "$MODE" = "html" -o "$MODE" = "gh-pages" ] ; then
4446
echo "Main CSS style file (css/style.css) not found. It will be created using a script..."
4547
mkdir -p "${SRC}/css"
4648
cp /usr/local/src/style.css "${SRC}/css/style.css"
49+
CLEAN_STYLE=true
4750
fi
4851

4952
# Javascript should be provided inside a "js" folder but the default, base script file should be called script.js.
@@ -52,6 +55,7 @@ if [ "$MODE" = "HTML" -o "$MODE" = "html" -o "$MODE" = "gh-pages" ] ; then
5255
echo "Main JS script file (js/script.js) not found. It will be created using a script..."
5356
mkdir -p "${SRC}/js"
5457
cp /usr/local/src/script.js "${SRC}/js/script.js"
58+
CLEAN_SCRIPT=true
5559
fi
5660

5761
# Mirrors the directory structure
@@ -69,6 +73,24 @@ if [ "$MODE" = "HTML" -o "$MODE" = "html" -o "$MODE" = "gh-pages" ] ; then
6973
fi
7074
fi
7175

76+
if [ "${CLEAN_TOC}" = true ] ; then
77+
rm "${TOC}"
78+
fi
79+
80+
if [ "${CLEAN_INDEX}" = true ] ; then
81+
rm "${SRC}/index.md"
82+
fi
83+
84+
if [ "${CLEAN_STYLE}" = true ] ; then
85+
rm "${SRC}/css/style.css"
86+
find "${SRC}/css" -type d -empty -delete
87+
fi
88+
89+
if [ "${CLEAN_SCRIPT}" = true ] ; then
90+
rm "${SRC}/js/script.js"
91+
find "${SRC}/js" -type d -empty -delete
92+
fi
93+
7294
# Print results
7395
echo "Done. Result:"
7496
tree $DEST

0 commit comments

Comments
 (0)