Skip to content

Instantly share code, notes, and snippets.

@mouradev
Last active October 4, 2019 12:01
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mouradev/9ddddb473d7cb22f5e535c75b9cc84a0 to your computer and use it in GitHub Desktop.
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)
#!/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