Skip to content

Commit

Permalink
Add sizes to build.
Browse files Browse the repository at this point in the history
Add sizes utility from Timezone. Display minified size during tests so
that they show up in Travis CI output.

Closes #22.
Closes #21.
  • Loading branch information
flatheadmill committed Jul 5, 2012
1 parent 907dce6 commit 9c1806e
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 1 deletion.
28 changes: 28 additions & 0 deletions build/sizes
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash

declare -A b
declare -A k

printf " %-24s %11s %11s %11s %11s\n" File Raw Min Zip Min/Zip
for file in $@; do
b[raw]=$(cat $file | wc -c)
b[min]=$(cat $file | uglifyjs | wc -c)
alt=$(cat $file | uglifyjs --lift-vars | wc -c)
if [ $alt -lt ${b[min]} ]; then
b[min]=$alt
fi
b[zip]=$(cat $file | gzip -c | wc -c)
b[minzip]=$(cat $file | uglifyjs | gzip -c | wc -c)
alt=$(cat $file | uglifyjs --lift-vars | gzip -c | wc -c)
if [ $alt -lt ${b[minzip]} ]; then
b[minzip]=$alt
fi
for field in raw min zip minzip; do
k[$field]=$(echo "${b[$field]} / 1024" | bc -l)
done
printf " %-24s" $file
for field in raw min zip minzip; do
printf "%6d/%05.2f" ${b[$field]} ${k[$field]}
done
printf "\n"
done
31 changes: 31 additions & 0 deletions build/test
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash

set -e

if [ "$TRAVIS" = "true" ]; then
sudo apt-get install -q -q bc 2> /dev/null > /dev/null && echo 'Installed `bc`.' && echo ''
fi

build/sizes index.js

echo ""

(proof run t/*/*.t | tee .proof.out | proof progress) || (proof errors < .proof.out) || exit 1

if [ "$TRAVIS" = "true" ] || [ "$MINIFY" = "true" ]; then
echo ""
echo "minified"
echo ""
default=$(cat index.js | uglifyjs | gzip -c | wc -c)
lift=$(cat index.js | uglifyjs --lift-vars | gzip -c | wc -c)

bak=index-$(date +'%FT%T').js
mv index.js $bak
if [ $default -lt $lift ]; then
cat $bak | uglifyjs > index.js
else
cat $bak | uglifyjs --lift-vars > index.js
fi

(proof run t/*/*.t | tee .proof.out | proof progress) || (proof errors < .proof.out) || exit 1
fi
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@
}]
, "homepage": "http://bigeasy.github.com/cadence"
, "repository": "git://github.com/bigeasy/cadence.git"
, "scripts" : { "test": "proof t/*/*.t" }
, "scripts" : { "test": "build/test" }
, "devDependencies":
{ "proof": "0.0.10"
, "uglify-js": ">=0"
}
, "dependencies": {}
}

0 comments on commit 9c1806e

Please sign in to comment.