You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ti...@apache.org on 2012/10/08 23:10:04 UTC
webworks commit: Made addWebworks script more robust - checks for
existing references of webworks.js
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 <ti...@nitobi.com>
Authored: Mon Oct 8 14:09:56 2012 -0700
Committer: Tim Kim <ti...@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