make embeds and variable replacements optional
This commit is contained in:
parent
06a2e0b55f
commit
00264d76e8
12
mige.sh
12
mige.sh
@ -12,6 +12,8 @@ TEMPLATE_FOOTER=${TEMPLATE_FOOTER:-templates/footer.html}
|
||||
SOURCEDIR=$PWD
|
||||
|
||||
OPTION_ASSETS=false
|
||||
OPTION_EMBEDS=false
|
||||
OPTION_VARIABLES=false
|
||||
|
||||
check_files () {
|
||||
if [ ! -f "$SOURCEDIR/$TEMPLATE_HEADER" ]; then echo "Header template '$TEMPLATE_HEADER' doesn't exist."; exit 2; fi
|
||||
@ -23,10 +25,12 @@ check_files () {
|
||||
}
|
||||
|
||||
read_options() {
|
||||
while getopts "ad:" opt; do
|
||||
while getopts "ad:ev" opt; do
|
||||
case "${opt}" in
|
||||
a) OPTION_ASSETS=true;;
|
||||
d) SOURCEDIR=$OPTARG; echo "Using project directory '$SOURCEDIR'.";;
|
||||
e) OPTION_EMBEDS=true;;
|
||||
v) OPTION_VARIABLES=true;;
|
||||
\?) exit 2;;
|
||||
esac
|
||||
done
|
||||
@ -71,8 +75,12 @@ process_file () {
|
||||
local file_output=$( echo "$1" | sed "s/$sourcediresc\/$DIR_CONTENT/$sourcediresc\/$DIR_DIST/" )
|
||||
cat "$SOURCEDIR/$TEMPLATE_HEADER" "$1" "$SOURCEDIR/$TEMPLATE_FOOTER" > $file_output
|
||||
|
||||
replace_variables $file_output
|
||||
if [ $OPTION_EMBEDS = true ]; then
|
||||
replace_embeds $file_output
|
||||
fi
|
||||
if [ $OPTION_VARIABLES = true ]; then
|
||||
replace_variables $file_output
|
||||
fi
|
||||
|
||||
timep=$((($(date +%s%N) - $timep)/1000000))
|
||||
echo -e "\e[32mFile $1 processed to $file_output ($timep ms).\e[0m"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user