diff --git a/build/build.sh b/build/build.sh index 7771aae..7817c62 100755 --- a/build/build.sh +++ b/build/build.sh @@ -9,14 +9,14 @@ read CONFIRM_RUN # Confirmation must begin with "y" if [[ $CONFIRM_RUN =~ ^y ]] then - + # Switch to parent directory - cd $(dirname $0) + cd "$(dirname "$0")" cd ../ - + # Retrieve name of current branch - BRANCH=$(git rev-parse --abbrev-ref HEAD) - + BRANCH="$(git rev-parse --abbrev-ref HEAD)" + # Define file paths SOURCE=jcanvas.js MINIFIED=jcanvas.min.js @@ -26,67 +26,67 @@ then README=README.md LICENSE=LICENSE.txt COMPILER=build/compiler.jar - + # Derive this jCanvas version from the date - VERSION=$(date +"%g.%m.%d") - YEAR=$(date +"%Y") - + VERSION="$(date +"%g.%m.%d")" + YEAR="$(date +"%Y")" + # Ask before building jCanvas if [[ $(git diff --name-only $SOURCE 2> /dev/null) ]] then - + echo "Building jCanvas v$VERSION..." - + # Function to replace within file using pattern replace() { EXT=.bak sed -i$EXT -E s/$1/$2/g $3 rm $3$EXT } - - # Update version in all files + + # Update version in all files VERSION_PATT="([0-9]{2})\.([0-9]{2})\.([0-9]{2})" replace $VERSION_PATT $VERSION $SOURCE replace $VERSION_PATT $VERSION $MANIFEST replace $VERSION_PATT $VERSION $PACKAGE replace $VERSION_PATT $VERSION $BOWER - + # Update copyright year in all files YEAR_PATT="([0-9]{4})" replace $YEAR_PATT $YEAR $SOURCE replace $YEAR_PATT $YEAR $README replace $YEAR_PATT $YEAR $LICENSE - + # Compress jCanvas using Google Closure Compiler - java -jar $COMPILER --js $SOURCE --js_output_file $MINIFIED - + closure-compiler --js $SOURCE --js_output_file $MINIFIED + else - + echo "jCanvas has not changed since last release" - + fi - + # Stage all files git add -A - + # Display status of repository git status - + # If there are changes to be committed if [[ $(git diff 2> /dev/null) != 0 ]] then - + # Ask to commit changes echo -n "Commit changes? " read CONFIRM_COMMIT if [[ $CONFIRM_COMMIT =~ ^y ]] then - + # Enter a message to commit git commit echo # If jCanvas was built - if [[ $CONFIRM_BUILD =~ ^y ]] + if [[ $CONFIRM_BUILD =~ ^y ]] then # If tag already exists if [[ $(git show-ref --tags --quiet --verify -- "refs/tags/$TAG") ]] @@ -110,18 +110,18 @@ then else echo "Commit not pushed to GitHub." fi - + else - + git reset echo "Stage has been reset" - + fi - + fi - + fi # Signify end of script echo -echo "Done." \ No newline at end of file +echo "Done." diff --git a/build/compiler.jar b/build/compiler.jar deleted file mode 100644 index d377af7..0000000 Binary files a/build/compiler.jar and /dev/null differ