Added watch script

This commit is contained in:
2022-02-05 14:22:00 +01:00
parent b9733dc893
commit 5e1ea8d832
2 changed files with 52 additions and 0 deletions

3
.gitignore vendored
View File

@@ -1,2 +1,5 @@
.env
out/ out/
backend/
frontend/
TheAdversary/ TheAdversary/

49
watch.sh Normal file
View File

@@ -0,0 +1,49 @@
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