Skip to content

Commit

Permalink
move initial checks to a function, remove unused MAX_CORES var.
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanbeller committed Jan 16, 2013
1 parent 85123e5 commit b625eef
Showing 1 changed file with 19 additions and 17 deletions.
36 changes: 19 additions & 17 deletions image_optim.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,9 @@ echo "To kill the script, run"
echo "while true ;do ; killall optipng ; killall advpng ; killall pngcrush ; done"
echo "for a while"


VERBOSE=true
cpucores=`getconf _NPROCESSORS_ONLN`


if [[ $(git rev-parse --is-inside-work-tree) != "true" ]] >& /dev/null ; then
echo "fatal: Not a git repository!"
echo "Make sure to be in a git repo!"
echo "Exiting"
exit 2
fi

echo "WARNING, this script is supposed to be run in a git repo"
echo "We will create a new branch now which the scriptwill work in."
git branch script/image_optim
git checkout script/image_optim
echo "Done"

timestartglobal()
{
TSG=`date +%s.%N`
Expand Down Expand Up @@ -50,6 +36,23 @@ print()
${VERBOSE} && echo $1
}

make_sure_we_are_safe()
{
if [[ $(git rev-parse --is-inside-work-tree) != "true" ]] >& /dev/null ; then
echo "fatal: Not a git repository!"
echo "Make sure to be in a git repo!"
echo "Exiting"
exit 2
fi

echo "WARNING, this script is supposed to be run in a git repo"
echo "We will create a new branch now which the scriptwill work in."
git branch script/image_optim
git checkout script/image_optim
echo "Done"
}


jpeg_remove_comment_and_exiv()
{
print "Removing comments and exiv data from jpegs."
Expand Down Expand Up @@ -78,9 +81,8 @@ png_optimize_all()
print "optimizing pngs took $TD"
}

VERBOSE=true
MAX_CORES=8
timestartglobal
make_sure_we_are_safe
jpeg_remove_comment_and_exiv
png_optimize_all
wait
Expand Down

0 comments on commit b625eef

Please sign in to comment.