From c0a893a5c0fa40d36baf8ebe32b645ae383170d1 Mon Sep 17 00:00:00 2001 From: Michael Lynch Date: Sat, 21 Dec 2024 12:53:37 -0500 Subject: [PATCH] Use the set -e option in scripts.sh The set -e option tells /bin/sh to exit immediately when any command terminates with a failing exit code. Using this option allows us to simplify a lot of the logic and remove the && and || exit 1 clauses because they're not necessary with set -e. --- scripts.sh | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/scripts.sh b/scripts.sh index a6148b2..771489e 100755 --- a/scripts.sh +++ b/scripts.sh @@ -1,13 +1,17 @@ #!/bin/sh +# Exit on first failure. +set -e + gen() { go generate ./... } test_go() { - gen || exit 1 + gen # make some files for embed - mkdir -p ./frontend/build && touch ./frontend/build/index.html || exit 1 + mkdir -p ./frontend/build + touch ./frontend/build/index.html go test ./... } @@ -17,12 +21,14 @@ build() { test_go root=$(pwd) - mkdir build + mkdir -p ./build echo "building frontend" - cd ./frontend && npm i && npm run build || exit 1 - cd $root || exit 1 + cd ./frontend + npm i + npm run build + cd $root echo "building backend" - go build -o ./build/fusion ./cmd/server/* || exit 1 + go build -o ./build/fusion ./cmd/server/* } dev() {