Skip to content

Commit

Permalink
Modify build script to use closure-compiler package
Browse files Browse the repository at this point in the history
  • Loading branch information
caleb531 committed May 15, 2015
1 parent b805f7a commit a5caae0
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 31 deletions.
62 changes: 31 additions & 31 deletions build/build.sh
Expand Up @@ -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
Expand All @@ -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") ]]
Expand All @@ -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."
echo "Done."
Binary file removed build/compiler.jar
Binary file not shown.

0 comments on commit a5caae0

Please sign in to comment.