Skip to content

Instantly share code, notes, and snippets.

@zeroeth
Created December 10, 2014 18:25
Show Gist options
  • Select an option

  • Save zeroeth/6a11ae9ee1dddb6d7246 to your computer and use it in GitHub Desktop.

Select an option

Save zeroeth/6a11ae9ee1dddb6d7246 to your computer and use it in GitHub Desktop.
js cache invalidator
#!/bin/sh
# Helper for conditional inclusion of features.
function command_exists() {
type "$1" &> /dev/null ;
}
file_signature() {
if command_exists sha256
then
sha256sum $1 | awk '{ print $1 }'
else
shasum -a 256 $1 | awk '{ print $1 }'
fi
}
cat index.html.template |\
sed "s/{{build_date}}/$(date)/g" |\
sed "s/{{js_signature}}/$(file_signature dist/aris.js)/g" |\
sed "s/{{css_signature}}/$(file_signature styles/arisjs.css)/g" \
> index.html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment