Skip to content

Instantly share code, notes, and snippets.

@mmas
Created December 20, 2013 21:39
Show Gist options
  • Save mmas/8062064 to your computer and use it in GitHub Desktop.
Save mmas/8062064 to your computer and use it in GitHub Desktop.
Simple githook pre-commit. Uglify javascript and compile and compress less to css. Save as .git/hooks/pre-commit. uglifyJS2 - https://github.com/mishoo/UglifyJS2 lessc - https://github.com/less/less.js
# uglifyJS2 - https://github.com/mishoo/UglifyJS2
# lessc - https://github.com/less/less.js
STYLES=$(pwd)/PATH/TO/MAIN/LESS/FILE
JS_ROOT=$(pwd)/PATH/TO/JAVASCRIPT/FOLDER
echo "Uglifying javacript..."
for i in $(find $JS_ROOT -name "*.js" -not -name "*.min.js")
do
o=${i/.js/.min.js}
uglifyjs $i -m -c -o $o
git add $o
done
echo 'Done'
echo "Compiling less to css..."
i=$STYLES
o=${i/.less/.css}
lessc -x $i $o
git add $o
echo 'Done'
exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment