Files
build/watch.sh
2022-02-05 14:22:00 +01:00

50 lines
726 B
Bash

init() {
for dir in frontend backend out; do
if [ ! -d $dir ]; then
mkdir $dir
fi
done
}
build() {
pwd=$PWD
cd out/backend/
go build .
cp -rf TheAdversary database.sqlite3 ../
if [ ! -f ../../.env ]; then
cp -rf .env ../
else
cp ../../.env ../
fi
cd $pwd
}
start() {
pwd=$PWD
cd out/
./TheAdversary
cd $pwd
}
stop() {
kill $(pidof TheAdversary)
}
main() {
init
cp -rf frontend/ backend/ out/
build
if [ $? -eq 0 ]; then
start &
fi
while inotifywait -r -e modify frontend/ backend/; do
cp -rf frontend/ backend/ out/
build
stop
start &
done
}
main