Browse Source

improve handling of (existing) directories with copy parameter

mxmehl 3 years ago
parent
commit
64a492a244
1 changed files with 14 additions and 1 deletions
  1. 14
    1
      fsfe-preview.sh

+ 14
- 1
fsfe-preview.sh View File

@@ -80,7 +80,13 @@ if [ "$1" = "--copy" ]; then
80 80
     SRC_full=$(realpath $2)
81 81
     DST_full=$(echo $SRC_full | sed -E "s|$LOC_trunk|$LOC_out|")
82 82
     echo "[INFO] Copying $SRC_full to $DST_full..."
83
-    cp -R $SRC_full $DST_full
83
+    if [ -d "$SRC_full" ] && [ -e "$DST_full" ]; then
84
+      rm -rf "$DST_full"
85
+      cp -R $SRC_full $DST_full
86
+    else
87
+      cp -R $SRC_full $DST_full
88
+    fi
89
+    
84 90
     shift
85 91
   done
86 92
   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
96 102
   exit 1
97 103
 fi
98 104
 
105
+# CHECK whether the source file is a directory (only --copy allowed)
106
+if [ -d "$SRC_full" ]; then
107
+  echo "[ERROR] The given file \"$SRC_full\" is a directory. Those can only be copied by using --copy as a parameter."
108
+  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."
109
+  exit 1
110
+fi
111
+
99 112
 # TEST if a DEV SVN directory is used. If yes, copy clean file to this Dir
100 113
 if [ "$LOC_trunk_dev" != "" ]; then
101 114
   SRC_full_dev=$(echo $SRC_full | sed -E "s|$LOC_trunk|$LOC_trunk_dev|")

Loading…
Cancel
Save