Last active
December 7, 2018 00:36
-
-
Save charliecalvert/f927c792ac248f2069a629b46ce6ada8 to your computer and use it in GitHub Desktop.
[Run-All] Run a node js program that has a client and server directory #node #bash
This file contains 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
#! /usr/bin/env bash | |
if [[ -z $2 ]]; then | |
echo -e "==========================================================" | |
echo -e "Pass in a project directory and a parameter of a, b, or c." | |
echo -e " a) Run Client Server" | |
echo -e " b) Run Server" | |
echo -e " c) Start Service" | |
echo -e "For Run Server, you also need to pass in a port." | |
echo -e "==========================================================" | |
echo -e "Examples: " | |
echo -e " ./run-all week06-system-check a" | |
echo -e " ./run-all week06-system-check b 30034" | |
echo -e " ./run-all week06-system-check c" | |
echo -e "==========================================================" | |
exit | |
fi | |
function runClientServer() { | |
cd $1 | |
pwd | |
try-run-both build | |
cd .. | |
} | |
function runServer() { | |
cd $1/client | |
pwd | |
./build-copy-worker a | |
cd ../server | |
nohup node bin/www & | |
firefox http://localhost:${2} | |
} | |
function startService() { | |
cd $1/server | |
pwd | |
./run-setup-service | |
} | |
case $2 in | |
[Aa]* ) runClientServer ${1}; shift;; | |
[Bb]* ) runServer ${1} ${3}; shift;; | |
[Cc]* ) startService ${1}; shift;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment