Skip to content

Instantly share code, notes, and snippets.

@allex
Last active August 29, 2015 14:25
Show Gist options
  • Save allex/c0a3a6d302996ffa2f1d to your computer and use it in GitHub Desktop.
Save allex/c0a3a6d302996ffa2f1d to your computer and use it in GitHub Desktop.
#!/bin/sh -e
# ================================================
# Description: update static resource revision
# Last Modified: Thu Jul 16, 2015 03:32PM
# Author: Allex Wang ([email protected])
# GistID: c0a3a6d302996ffa2f1d
# GistURL: https://gist.github.com/c0a3a6d302996ffa2f1d
# ================================================
dir=`cd $(dirname $0); pwd -P`
# git co HEAD .
# ver=`git rev-parse --short master`
ver=`date | sha1sum`
ver="${ver:0:16}"
[ $? -eq 0 ] || read -p "Please entre the cdn cache version stamp: " ver
find $dir -name "*.*html" -print0| \
xargs -0 grep --color=none -i '\.\(css\|js\)\(?v=[^"]*\|[^"]*\)"' -l | \
xargs sed -i"" -e "s/\.\(css\|js\)\(?v=[^\"]*\|[^\"]*\)\"/.\1?v=${ver}\"/g"
# git co HEAD .
echo "done. (ver: $ver)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment