Skip to content

Instantly share code, notes, and snippets.

@brentonhouse
Forked from jmcerrejon/backup.sh
Created March 11, 2021 23:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brentonhouse/1a04759c96b067985636698cfd618161 to your computer and use it in GitHub Desktop.
Save brentonhouse/1a04759c96b067985636698cfd618161 to your computer and use it in GitHub Desktop.
Zip the current Titanium project on macOS
#!/usr/bin/bash
#
# Description: Zip the current Titanium project on macOS
# File: backup.sh
# Author: Jose Cerrejon (ulysess_at_gmail.com)
# Help: Copy in the root of your Titanium project and Add to package.json the script: "backup": "sh backup.sh",
#
clear
stop_liveview() {
local TITANIUM_SDK_PATH
local LATEST_SDK_VERSION
local LIVE_SERVER_PATH
TITANIUM_SDK_PATH="$HOME/Library/Application Support/Titanium/mobilesdk/osx/"
LATEST_SDK_VERSION=$(ls "$TITANIUM_SDK_PATH" | head -n 1)
LIVE_SERVER_PATH="${TITANIUM_SDK_PATH}/${LATEST_SDK_VERSION}/node_modules/liveview/bin/liveview-server"
if [[ -e $LIVE_SERVER_PATH ]]; then
printf "\nStopping Live servers..."
"$LIVE_SERVER_PATH" stop
fi
}
clean() {
printf "\nCleaning da hause...\n\n"
ti clean
}
backup() {
local DATE
local PROJECT_NAME
DATE=$(date +%Y%m%e-%H%M%S)
PROJECT_NAME=$(basename "$(pwd)")
cd .. || exit 1
printf "Zipping...\n"
zip -qq -r "$PROJECT_NAME"_"$DATE".zip "$PROJECT_NAME" -x ".DS*" -x "__MACOSX" -x "$PROJECT_NAME/node_modules/*"
printf "\nDone!...\n\n"
ls -la "$PROJECT_NAME"_*
}
stop_liveview
clean
backup
open -a "Finder" .
printf "\nPress a key to exit...\n"
read -r
exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment