Skip to content

Instantly share code, notes, and snippets.

Created January 8, 2013 20:31
Show Gist options
  • Save anonymous/4487663 to your computer and use it in GitHub Desktop.
Save anonymous/4487663 to your computer and use it in GitHub Desktop.
HTML5 Manifest Generator and Watcher
#!/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
@maurerbot
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment