Last active
December 10, 2015 20:18
-
-
Save 4x4notfound/4487697 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 and outputs a HTML5 Manifest to $OUT | |
#You may need to change the location of your depency scripts | |
#Dependencies: confess.js and phantomjs | |
#Usage: sh manigest_generator.sh <url> <dir> | |
#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 $1 appcache confess/config.json > $2" | |
update_sha() | |
{ | |
sha=`ls -lR $2 | shasum` | |
} | |
build () { | |
echo "--> running..." | |
echo $cmd | |
## Build/make commands here | |
eval $cmd | |
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