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