Skip to content

Instantly share code, notes, and snippets.

@moduscreate
Created July 20, 2012 13:38
Show Gist options
  • Save moduscreate/3150751 to your computer and use it in GitHub Desktop.
Save moduscreate/3150751 to your computer and use it in GitHub Desktop.
######## WATCHER SCRIPT. Runs very .5 seconds, checks for changes in the source 'html5' dir.
#!/bin/sh
MD5=`cat /tmp/watcher.md5 | awk '{print $4}'`;
X=0;
while [ $X -eq 0 ]; do
newMD5=`ls -altR html5/ | grep -v app.json > /tmp/watcher.md5 && md5 /tmp/watcher.md5 | awk '{print $4}'`;
if [[ "$MD5" != "$newMD5" ]]; then
echo
echo "Change found, deploying! `date`"
./deploy.sh
if [ $? -eq 0 ] ; then
MD5=$newMD5;
fi
else
printf .
fi
sleep .5
done
########### deployer script. Executed by watch.sh, builds a "testing" copy of Sencha Touch2, copies testing build to android & ios projects and copies respective cordova js files.
#!/bin/sh
target=testing;
buildDir="../build/$target"
androidDir="../android/assets/www"
iosDir="../ios/www"
echo $'\e[32m''building Sencha ../ios/www' $'\e[00m'
#sencha app build testing ../ios/www/ > /tmp/st2.out
cd html5/
sencha app build $target >/tmp/st2.out 2>&1
isError=`grep ERROR /tmp/st2.out | > /dev/null 2>&1`
if [ $? -gt 0 ]; then
echo $'\e[31m''Sencha build error' $'\e[00m'
osascript -e 'tell application "Finder"' -e "activate" -e "display dialog \"Erorr with Sencha Touch 2 build\"" -e 'end tell'
cat /tmp/st2.out
cd ..
else
echo $'\e[32m''Sencha build DONE' $'\e[00m'
echo "Copying to android..."
rm -rf $androidDir/*
cp -Rf $buildDir/* $androidDir/
cp lib/cordova-1.9.0.android.js $androidDir/cordova-1.9.0.js
echo "Copying to ios..."
rm -rf $iosDir/*
cp -Rf $buildDir/* $iosDir/
cp lib/cordova-1.9.0.ios.js $iosDir/cordova-1.9.0.js
echo "DONE.."
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment