Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

move initial checks to a function, remove unused MAX_CORES var.

  • Loading branch information...
commit b625eef0020e32004aaf27e146079ec055121532 1 parent 85123e5
@stefanbeller stefanbeller authored
Showing with 19 additions and 17 deletions.
  1. +19 −17 image_optim.sh
View
36 image_optim.sh
@@ -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`
@@ -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."
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.