File tree Expand file tree Collapse file tree 1 file changed +13
-6
lines changed
Expand file tree Collapse file tree 1 file changed +13
-6
lines changed Original file line number Diff line number Diff line change 11#! /bin/bash
22
3+ set -e # Exit immediately if any command fails
34
45export NEXT_PUBLIC_MEILISEARCH_ORIGIN=" http://localhost:7700"
56export NEXT_PUBLIC_MEILISEARCH_API_KEY=" fern123!"
67
78ENV_LOCAL_PATH=" packages/fern-docs/bundle/.env.local"
89ENV_LOCAL_BACKUP=" packages/fern-docs/bundle/.env.local.bak"
910
11+ # Function to restore .env.local if it was backed up
12+ cleanup () {
13+ if [ -f " $ENV_LOCAL_BACKUP " ]; then
14+ echo " restoring .env.local from backup..."
15+ mv " $ENV_LOCAL_BACKUP " " $ENV_LOCAL_PATH "
16+ fi
17+ }
18+
19+ # Set trap to run cleanup on exit (success or failure)
20+ # This ensures .env.local is always restored, even if the build fails
21+ trap cleanup EXIT
22+
1023# move .env.local to a backup if it exists
1124if [ -f " $ENV_LOCAL_PATH " ]; then
1225 echo " temporarily moving .env.local to backup..."
@@ -19,9 +32,3 @@ cp -r packages/fern-docs/bundle/.next/static packages/fern-docs/bundle/.next/sta
1932find packages/fern-docs/bundle/.next -depth -mindepth 1 -not -path " packages/fern-docs/bundle/.next/standalone*" -exec rm -rf {} \;
2033rm -rf packages/fern-docs/bundle/.next/standalone/node_modules/.pnpm/
[email protected] && rm -rf packages/fern-docs/bundle/.next/standalone/node_modules/.pnpm/@
[email protected] 2134tar -czf docs_bundle.tar.gz -C packages/fern-docs/bundle/.next/standalone .
22-
23- # move .env.local back if it was backed up
24- if [ -f " $ENV_LOCAL_BACKUP " ]; then
25- echo " restoring .env.local from backup..."
26- mv " $ENV_LOCAL_BACKUP " " $ENV_LOCAL_PATH "
27- fi
You can’t perform that action at this time.
0 commit comments