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 2013/03/18 22:21:45 UTC

webworks commit: Fix create script for Linux

Updated Branches:
  refs/heads/master c0af8ba61 -> 1e9e95ad5


Fix create script for Linux

This fix is copied from the Android create script. OSX requires the -i
parameter to include an extension (in this case an empty string),
whereas it is not required on Linux (leading to the empty string being
interpreted as the filename).


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

Branch: refs/heads/master
Commit: 1e9e95ad56154ba736a35d025e6405a7ce6b9e29
Parents: c0af8ba
Author: Darryl Pogue <da...@dpogue.ca>
Authored: Sun Mar 17 22:05:26 2013 -0700
Committer: Tim Kim <ti...@adobe.com>
Committed: Mon Mar 18 13:41:09 2013 -0700

----------------------------------------------------------------------
 bin/create |   21 +++++++++++++++++----
 1 files changed, 17 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/1e9e95ad/bin/create
----------------------------------------------------------------------
diff --git a/bin/create b/bin/create
index 870bad1..b7e719b 100755
--- a/bin/create
+++ b/bin/create
@@ -56,6 +56,19 @@ function on_error {
     [ -d "$PROJECT_PATH" ] && rm -rf "$PROJECT_PATH"
 }
 
+function replace {
+    local pattern=$1
+    local filename=$2
+    # Mac OS X requires -i argument
+    if [[ "$OSTYPE" =~ "darwin" ]]
+    then
+        /usr/bin/sed -i '' -e $pattern "$filename"
+    elif [[ "$OSTYPE" =~ "linux" ]]
+    then
+        /bin/sed -i -e $pattern "$filename"
+    fi
+}
+
 # we do not want the script to silently fail
 trap on_error ERR
 trap on_exit EXIT
@@ -79,13 +92,13 @@ then
 	(cd "$BUILD_PATH" && "$ANT" create -Dproject.path="$PROJECT_PATH" &> /dev/null )
     # interpolate the activity and package into config.xml
     echo "Updating config.xml ..."
-    sed -i '' -e "s/__NAME__/${NAME}/g" "$MANIFEST_PATH"
-    sed -i '' -e "s/__PACKAGE__/${PACKAGE}/g" "$MANIFEST_PATH"
+    replace "s/__NAME__/${NAME}/g" "$MANIFEST_PATH"
+    replace "s/__PACKAGE__/${PACKAGE}/g" "$MANIFEST_PATH"
 else
 	# copy project template if in distribution
 	echo "Copying assets and resources ..."
 	cp -r "$BUILD_PATH/sample/." "$PROJECT_PATH"
     echo "Updating config.xml ..."
-    sed -i '' -e "s/cordovaExample/${NAME}/g" "$MANIFEST_PATH"
-    sed -i '' -e "s/org.apache.cordova.example/${PACKAGE}/g" "$MANIFEST_PATH"
+    replace "s/cordovaExample/${NAME}/g" "$MANIFEST_PATH"
+    replace "s/org.apache.cordova.example/${PACKAGE}/g" "$MANIFEST_PATH"
 fi