Skip to content

Commit 9183ad1

Browse files
chore(internal): support env vars in ./scripts/repl
1 parent d84f8a5 commit 9183ad1

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

scripts/repl

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
#!/usr/bin/env bash
22

3+
if [ -z "$BEEPER_ACCESS_TOKEN" ]; then
4+
echo 'ERROR: BEEPER_ACCESS_TOKEN environment variable is required but not set'
5+
exit 1
6+
fi
7+
38
echo "==> Detecting PostgreSQL Python executable"
49
PYTHON_EXECUTABLE_PATH=$(pg_config --configure | grep -o "PYTHON=[^ ]*" | cut -d= -f2 | tr -d "'")
510
echo "PostgreSQL uses Python $PYTHON_EXECUTABLE_PATH"
@@ -29,8 +34,8 @@ if [ "$PG_MAJOR_VERSION" -ge 18 ]; then
2934
done
3035
POSTGRES_CONFIG=(-c extension_control_path="$(realpath temp/install/share/postgresql)")
3136
else
32-
# In PostgreSQL <18 we cannot point `postgres` to our local extensions directory. So we install directly to
33-
# the system.
37+
# In PostgreSQL <18 we cannot point `postgres` to our local extensions directory. So we install
38+
# directly to the system.
3439
sudo make install PG_CONFIG="$(command -v pg_config)"
3540
fi
3641

@@ -61,10 +66,15 @@ done
6166
echo "==> Running setup.sql"
6267
psql -d postgres -f test/sql/create_extension.sql
6368

69+
psql -d postgres --variable "value='$BEEPER_ACCESS_TOKEN'" -c 'ALTER DATABASE postgres SET beeper_desktop_api.beeper_access_token = :value;'
70+
if [ -n "$BEEPER_DESKTOP_BASE_URL" ]; then
71+
psql -d postgres --variable "value='$BEEPER_DESKTOP_BASE_URL'" -c 'ALTER DATABASE postgres SET beeper_desktop_api.base_url = :value;'
72+
fi
73+
6474
if command -v pgcli &>/dev/null; then
6575
echo "==> Starting pgcli REPL"
6676
pgcli postgres
6777
else
6878
echo "==> Starting psql REPL (TIP: Install pgcli for better autocomplete!)"
6979
psql -d postgres
70-
fi
80+
fi

0 commit comments

Comments
 (0)