diff --git a/bin/create b/bin/create index 688b5fd0..a12a715e 100755 --- a/bin/create +++ b/bin/create @@ -63,6 +63,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 = 'darwin11' ] + then + sed -i '' -e $pattern $filename + elif [ $OSTYPE = 'linux-gnu' ] + then + sed -i -e $pattern $filename + fi +} + # we do not want the script to silently fail trap on_error ERR trap on_exit EXIT @@ -116,12 +129,12 @@ fi # interpolate the activity name and package cp $BUILD_PATH/bin/templates/project/Activity.java $ACTIVITY_PATH -sed -i '' -e "s/__ACTIVITY__/${ACTIVITY}/g" $ACTIVITY_PATH -sed -i '' -e "s/__ID__/${PACKAGE}/g" $ACTIVITY_PATH +replace "s/__ACTIVITY__/${ACTIVITY}/g" $ACTIVITY_PATH +replace "s/__ID__/${PACKAGE}/g" $ACTIVITY_PATH cp $BUILD_PATH/bin/templates/project/AndroidManifest.xml $MANIFEST_PATH -sed -i '' -e "s/__ACTIVITY__/${ACTIVITY}/g" $MANIFEST_PATH -sed -i '' -e "s/__PACKAGE__/${PACKAGE}/g" $MANIFEST_PATH +replace "s/__ACTIVITY__/${ACTIVITY}/g" $MANIFEST_PATH +replace "s/__PACKAGE__/${PACKAGE}/g" $MANIFEST_PATH # creating cordova folder and copying emulate/debug/log/launch scripts mkdir $PROJECT_PATH/cordova