Created
January 8, 2013 20:31
-
-
Save anonymous/4487663 to your computer and use it in GitHub Desktop.
HTML5 Manifest Generator and Watcher
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#This script watches your project folder ($DIR) and outputs a HTML5 Manifest to $OUT | |
#You may need to change the location of your depency scripts | |
#Dependencies: confess.js and phantomjs | |
#Author Adrian Maurer (https://github.com/adrianmaurer) | |
#Based on http://stackoverflow.com/questions/2972765/linux-script-that-monitors-file-changes-within-folders-like-autospec-does | |
#sh manifest_generator.sh $URL $DIR $OUT | |
sha=0 | |
previous_sha=0 | |
CMD = "phantomjs/phantomjs confess/confess.js $0 appcache confess/config.json > $2" | |
update_sha() | |
{ | |
sha=`ls -lR $1 | shasum` | |
} | |
build () { | |
echo "--> running confess.js appcache for $0" | |
$CMD | |
## Build/make commands here | |
echo | |
echo "--> Monitor: Monitoring filesystem..." | |
} | |
changed () { | |
echo "--> Monitor: Files changed, Building..." | |
build | |
previous_sha=$sha | |
} | |
compare () { | |
update_sha | |
if [[ $sha != $previous_sha ]] ; then changed; fi | |
} | |
run () { | |
while true; do | |
compare | |
sleep 5 | |
done | |
} | |
echo "--> Monitor: Init..." | |
echo "--> Monitor: Monitoring filesystem..." | |
run |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
corrected version https://gist.github.com/4487697