Files
zulip-desktop/zulip-electron-launcher.sh
Akash Nimare 405d938223 Update docs and code to point to new repo url.
This is because we have changed the repo name to zulip-desktop.
2019-05-21 02:33:13 +05:30

122 lines
2.0 KiB
Bash
Executable File

#!/bin/bash
# Zulip Beta Client Launcher
# This script ensures that you have the latest version of the specified branch
# (defaults to master if none specified) and then updates or installs all your
# required npm modules.
# I recommend symlinking this script into your PATH.
# {{{ showUsage()
showUsage()
{
echo "Usage: $0 <branch_name>"
echo "Example: $0 dev"
exit 1
}
# }}}
# {{{ envSetup()
envSetup()
{
defaultBranch="master"
startingDir=`pwd`
requirePop=0
# Check command line arguments
if [ "$#" -gt "1" ]
then
showUsage
elif [ "$#" -eq "1" ]
then
myBranch=$1
else
myBranch=$defaultBranch
fi
# Set workingDir
if [ -L $0 ]
then
realPath=`ls -l $0 | cut -d '>' -f 2`
workingDir=`dirname $realPath`
else
workingDir="."
fi
# Set name of upstreamRemote
cd $workingDir
git remote -v | grep "github\.com.zulip.zulip-desktop.git (fetch)" > /dev/null 2>&1
if [ $? -eq 0 ]
then
upstreamRemote=`git remote -v | grep "github\.com.zulip.zulip-desktop.git (fetch)" | awk '{ print $1 }'`
else
upstreamRemote="origin"
fi
}
# }}}
# {{{ gitCheckout()
gitCheckout()
{
git fetch $upstreamRemote
git checkout $myBranch
git rebase $upstreamRemote/master
if [ $? -gt 0 ]
then
echo "Stashing uncommitted changes and doing a new git pull"
git stash && requirePop=1
git rebase $upstreamRemote/master
fi
}
# }}}
# {{{ npmInstallStart()
npmInstallStart()
{
npm install
npm start &
}
# }}}
# {{{ cleanUp()
cleanUp()
{
# Switch back to branch we started on
git checkout -
# Pop if we stashed
if [ $requirePop -eq 1 ]
then
echo "Popping out uncommitted changes"
git stash pop
fi
# Return the whatever dir we started in
cd $startingDir
}
# }}}
# this function is called when user hits Ctrl-C
catchControl_c () {
echo -en "\n## Ctrl-C caught; Quitting \n"
# exit shell script
exit $?;
}
envSetup $*
gitCheckout
npmInstallStart
cleanUp
# initialise trap to call catchControl_c function and trap keyboard interrupt (control-c)
trap catchControl_c SIGINT
sleep 1000