Aggregating and uglifying javascript in a git pre-commit hook

徘徊边缘 提交于 2020-01-02 07:38:56

问题


I'm using ready.js to aggregate JS files into an all.js file (without Google's Closure Compiler), and then using uglify-js to minify and obfuscate the code. I'd like to do all of this in a pre-commit hook.

However, I think I'm doing something wrong.

My .git/hooks/pre-commit file looks like this:

#!/bin/sh
readyjs ~/Sites/backbone/js/javascripts/ ~/Sites/backbone/js/ --nojslint -o "underscore.js, backbone.js" --nocompiler
uglifyjs -nm -o ~/Sites/backbone/js/all.min.js ~/Sites/backbone/js/all.js
# Commit
exit

Should I not be using simple Bash here? Is there something else I'm doing wrong? This step seems to be skipped entirely.


回答1:


My psychic powers suggest that your script isn't executable; try doing

chmod +x .git/hooks/pre-commit


来源:https://stackoverflow.com/questions/8598246/aggregating-and-uglifying-javascript-in-a-git-pre-commit-hook

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!