diff --git a/fsfe-preview.sh b/fsfe-preview.sh index 59c28fb..f2e340b 100755 --- a/fsfe-preview.sh +++ b/fsfe-preview.sh @@ -80,7 +80,13 @@ if [ "$1" = "--copy" ]; then SRC_full=$(realpath $2) DST_full=$(echo $SRC_full | sed -E "s|$LOC_trunk|$LOC_out|") echo "[INFO] Copying $SRC_full to $DST_full..." - cp -R $SRC_full $DST_full + if [ -d "$SRC_full" ] && [ -e "$DST_full" ]; then + rm -rf "$DST_full" + cp -R $SRC_full $DST_full + else + cp -R $SRC_full $DST_full + fi + shift done echo "[SUCCESS] Copying finished. Files should be visible via the local webserver now." @@ -96,6 +102,13 @@ if [ ! $(echo $SRC_full | grep "$LOC_trunk") ]; then exit 1 fi +# CHECK whether the source file is a directory (only --copy allowed) +if [ -d "$SRC_full" ]; then + echo "[ERROR] The given file \"$SRC_full\" is a directory. Those can only be copied by using --copy as a parameter." + echo "NOTE: Using --copy won't build potential .xhtml files inside a directory. If you have this case, please first copy an empty directory and then build the .xhtml files inside them." + exit 1 +fi + # TEST if a DEV SVN directory is used. If yes, copy clean file to this Dir if [ "$LOC_trunk_dev" != "" ]; then SRC_full_dev=$(echo $SRC_full | sed -E "s|$LOC_trunk|$LOC_trunk_dev|")