cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tim...@apache.org
Subject webworks commit: Made addWebworks script more robust - checks for existing references of webworks.js
Date Mon, 08 Oct 2012 21:10:04 GMT
Updated Branches:
  refs/heads/master f1b9eada0 -> dfd79ee07


Made addWebworks script more robust - checks for existing references of webworks.js


Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-blackberry-webworks/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-blackberry-webworks/commit/dfd79ee0
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-blackberry-webworks/tree/dfd79ee0
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-blackberry-webworks/diff/dfd79ee0

Branch: refs/heads/master
Commit: dfd79ee07f79ecfb833db15bae68b4e030ac64c0
Parents: f1b9ead
Author: Tim Kim <tim.kim@nitobi.com>
Authored: Mon Oct 8 14:09:56 2012 -0700
Committer: Tim Kim <tim.kim@nitobi.com>
Committed: Mon Oct 8 14:09:56 2012 -0700

----------------------------------------------------------------------
 bin/templates/project/cordova/addWebworks |   37 ++++++++++++++++--------
 1 files changed, 25 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-blackberry-webworks/blob/dfd79ee0/bin/templates/project/cordova/addWebworks
----------------------------------------------------------------------
diff --git a/bin/templates/project/cordova/addWebworks b/bin/templates/project/cordova/addWebworks
index 6fc2d3b..1a23ed2 100755
--- a/bin/templates/project/cordova/addWebworks
+++ b/bin/templates/project/cordova/addWebworks
@@ -26,19 +26,32 @@ then
   exit 0
 fi
 
-if [ ! -e "www/js/webworks.js" ]
-then
-    echo 'www/js/webworks.js file not found - need to build project...'
-    $ANT qnx build
-fi
+# cleanup after exit and/or on error
+function on_exit {
+    echo "\nDone!"
+    echo "Remember to build your qnx project to get the webworks.js file in your js directory!\n"
+}
+
+function on_error {
+    echo "An error occured."
+}
+
+# we do not want the script to silently fail
+trap on_error ERR
+trap on_exit EXIT
+
+echo "Finding files to add webworks to... \n"
 
 find www -name \*.html\* | while read fullpath
 do
-    # i hate regex
-    jspath=$( dirname "$fullpath" ) ; jspath=${jspath#./www} ; jspath=${jspath//\/[a-zA-Z0-9]/../}
; jspath=${jspath//[a-zA-Z0-9]/}
-    sed -i "" '/<head>/ a\
-    <script type="text/javascript" src="'$jspath'js/webworks.js"></script>' $fullpath
   
+    if grep "webworks.js" $fullpath > /dev/null
+    then
+        echo "SKIPPING: "$fullpath
+    else
+        # i hate regex
+        jspath=$( dirname "$fullpath" ) ; jspath=${jspath#./www} ; jspath=${jspath//\/[a-zA-Z0-9]/../}
; jspath=${jspath//[a-zA-Z0-9]/}
+        sed -i "" '/<head>/ a\
+        <script type="text/javascript" src="'$jspath'js/webworks.js"></script>'
$fullpath  
+        echo "ADDING: "$fullpath
+    fi
 done
-
-echo 'added webworks reference to these files: '
-find www -name \*.html\* | xargs -0 echo


Mime
View raw message