Merge pull request #6563 from colemanw/bin
[civicrm-core.git] / bin / setup.sh
index d0ed91589579a5934fdc904cb1f018e2f7381d9c..b242dc4ae1e4767f5a35750e9e7883718ea72178 100755 (executable)
@@ -155,8 +155,20 @@ if [ -n "$DO_DOWNLOAD" ]; then
       NODE=$(pickcmd node nodejs)
       BOWER="$NODE $BOWER"
     fi
-    # Without the force flag bower won't check for new versions or verify that installed software matches version specified in bower.json
-    $BOWER install -f
+    # Without the force flag, bower may not check for new versions or verify that installed software matches version specified in bower.json
+    # With the force flag, bower will ignore all caches and download all deps.
+    if [ -n "$OFFLINE" ]; then
+      BOWER_OPT=
+    elif [ ! -f "bower_components/.setupsh.ts" ]; then
+      ## First run -- or cleanup from failed run
+      BOWER_OPT=-f
+    elif [ "bower.json" -nt "bower_components/.setupsh.ts" ]; then
+      ## Bower.json has changed since last run
+      BOWER_OPT=-f
+    fi
+    [ -f "bower_components/.setupsh.ts" ] && rm -f "bower_components/.setupsh.ts"
+    $BOWER install $BOWER_OPT
+    touch bower_components/.setupsh.ts
   popd
 fi