Last active
October 4, 2019 12:01
-
-
Save mouradev/9ddddb473d7cb22f5e535c75b9cc84a0 to your computer and use it in GitHub Desktop.
Build and copy app to dist folder. the argument '-zip' can be passed to zip the build (Wordpress plugin like)
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/sh | |
DIST_DIR=dist | |
PROJECT_NAME=${PWD##*/} | |
# colors | |
lgreen="\033[1;32m" | |
green="\033[0;32m" | |
yellow="\033[1;33m" | |
red="\033[1;31m" | |
blue="\033[1;34m" | |
nc="\033[0m" | |
echo "\n================================================\n" | |
echo "${yellow}Building this app in ./dist folder ${green}\n" | |
if [ -d "$DIST_DIR" ]; then rm -Rf $DIST_DIR; fi | |
mkdir -p $DIST_DIR/$PROJECT_NAME | |
rsync -avh ./ $DIST_DIR/$PROJECT_NAME \ | |
--exclude $DIST_DIR \ | |
--exclude *.sql \ | |
--exclude build.sh \ | |
--exclude .git \ | |
--exclude .gitignore \ | |
--exclude .DS_Store | |
function done_msg() { | |
echo "${lgreen}== done! == ${nc}" | |
} | |
function zip_dist() { | |
echo "${nc}\n ========================= \n" | |
echo "${yellow}Zipping the builded app to $DIST_DIR/$PROJECT_NAME.zip ${nc}\n" | |
cd $DIST_DIR && zip -rq $PROJECT_NAME.zip $PROJECT_NAME/ \ | |
-x $PROJECT_NAME.zip | |
done_msg | |
} | |
if [ "$1" = "-zip" ]; then | |
zip_dist | |
exit; | |
fi | |
while true; do | |
echo ${blue} | |
read -p "Do you wish to zip this builded app? " yn | |
# echo "${nc}" | |
case $yn in | |
[Yy]* ) zip_dist ; break;; | |
[Nn]* ) done_msg ; exit;; | |
* ) echo "${red}Please answer yes or no. ${nc}";; | |
esac | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment