moodle_local_treestudyplan/vuemode.sh

39 lines
1.2 KiB
Bash
Raw Normal View History

2023-07-26 16:42:21 +02:00
#!/bin/bash
SCRIPTPATH="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
VUESRC="$SCRIPTPATH/amd/src/"
VUEBUILD="$SCRIPTPATH/amd/build"
VUEPROD="$SCRIPTPATH/amd/vue/prod"
VUEDEV="$SCRIPTPATH/amd/vue/dev"
VUEJS_MD5=($(md5sum $VUESRC/vue.js))
VUEPROD_MD5=($(md5sum $VUEPROD/vue.js))
VUEDEV_MD5=($(md5sum $VUEDEV/vue.js))
if [ $VUEJS_MD5 == $VUEDEV_MD5 ]; then
MODE="dev"
elif [ $VUEJS_MD5 == $VUEPROD_MD5 ]; then
MODE="prod"
elif [ "$2" != "-f" && "$1" != "query" ]; then
echo "ERROR: $VUELINK is not a a copy of either ../vue/vue-dev.js or ../vue/vue-prod.js"
echo "Maybe you manually changed it? Use -f to force overwrite in this case"
exit 1
fi
# SINCE the production version of vue.js s already minified, we may get away with simply copying it
# to the build directory
if [ "$1" == "dev" ]; then
cp $VUEDEV/vue.js $VUEBUILD/vue.min.js
cp $VUEDEV/vue.js $VUESRC/vue.js
rm $VUEBUILD/vue.min.js.map 2>/dev/null
elif [ "$1" == "prod" ]; then
cp $VUEPROD/vue.js $VUEBUILD/vue.min.js
cp $VUEPROD/vue.js $VUESRC/vue.js
rm $VUEBUILD/vue.min.js.map 2>/dev/null
elif [ "$1" == "query" ]; then
echo $MODE
else
echo "Switch VueJS between development and production mode"
echo "Usage:"
echo "$SCRIPTNAME <dev|prod|query> [-f]"
fi