-
-
Save baininghan/b892ce078f73c9ed166d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/zsh | |
| CUR_DIR=$PWD | |
| HEXO=/Users/wzpan/Documents/workspace/repositories/hexo-blog | |
| PUBLISH=/Users/wzpan/Documents/workspace/repositories/wzpan | |
| CSS=$HEXO/themes/bootstrap/source/css | |
| JS=$HEXO/themes/bootstrap/source/js | |
| DIST=$HEXO/themes/bootstrap/source/dist | |
| PUBLIC=$HEXO/public | |
| cd $HEXO | |
| hexo clean | |
| # Compress stylesheets and Javascripts | |
| cd $CSS | |
| for file in `basename -s .css *.css`;do | |
| yuicompressor ${file}.css -o $DIST/${file}.min.css | |
| done | |
| cd $JS | |
| for file in `basename -s .js *.js`;do | |
| yuicompressor ${file}.js -o $DIST/${file}.min.js | |
| done | |
| # Generate blog | |
| cd $HEXO | |
| hexo generate | |
| # Publish blog | |
| echo -n "Copy the compiled result to your site repo?[y/n]" | |
| read copy_yn | |
| if [ "$copy_yn" = "y" ]; then | |
| if [ -d $PUBLISH ] | |
| then | |
| cd $PUBLISH | |
| rm -r * | |
| fi | |
| cd $HEXO | |
| cp -av $PUBLIC/* $PUBLISH/ | |
| echo -n "Update your site repo?[y/n]" | |
| read update_site_yn | |
| case "$update_site_yn" in | |
| y ) | |
| cd $PUBLISH | |
| git add --all | |
| echo -e "\033[34m Please enter commit message: \033[0m" | |
| read commit_message | |
| git commit -m $commit_message | |
| git push -u origin gitcafe-pages:gitcafe-pages | |
| cd - | |
| echo "Congrats! The site repo has been updated" | |
| cd $HEXO | |
| git add --all | |
| git commit -m $commit_message | |
| git push | |
| cd - | |
| echo "Congrats! The blog repo has been updated" | |
| ;; | |
| n ) | |
| echo "Don't copy them this time." | |
| ;; | |
| *) | |
| echo "Please enter y or n." | |
| exit 1 | |
| ;; | |
| esac | |
| elif [ "$copy_yn" = "n" ]; then | |
| echo "Don't copy them this time." | |
| else | |
| echo "Please enter y or n." | |
| exit 1 | |
| fi | |
| echo "All done!" | |
| cd $CUR_DIR | |
| exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment