fix(frontend): move mock api files instead of removing

Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
This commit is contained in:
Tilman Vatteroth 2023-09-02 14:52:13 +02:00
parent dc48d52d75
commit 1f0439b618
4 changed files with 24 additions and 8 deletions

View file

@ -7,15 +7,29 @@
set -e
cleanup () {
if [ -d ../tmp/src/pages/api ]; then
echo "🦔 > Moving Mock API files back"
mv ../tmp/src/pages/api src/pages
fi
}
trap cleanup EXIT
echo "🦔 Frontend Production Build"
echo "🦔 > Clearing existing builds"
rm -rf dist/
echo "🦔 > Preparing files"
if [ "${1}" = "--keep-mock-api" ]; then
echo "🦔 > Keeping Mock API"
if [ ! -z "${NEXT_PUBLIC_USE_MOCK_API}" ]; then
echo "🦔 > Keeping Mock API because NEXT_PUBLIC_USE_MOCK_API is set"
if [ ! -d src/pages/api ]; then
echo "🦔 > ⚠️ src/pages/api doesn't exist"
fi
else
rm -rf src/pages/api
echo "🦔 > Moving Mock API because NEXT_PUBLIC_USE_MOCK_API is unset"
mkdir -p ../tmp/src/pages
mv src/pages/api ../tmp/src/pages/api
fi
echo "🦔 > Building"