From 34abe0e78301b187590a0fcddde95602dd8b8329 Mon Sep 17 00:00:00 2001 From: Maciek Sakrejda Date: Sat, 28 Jan 2023 16:44:13 -0800 Subject: [PATCH] Add support for DATABASE_URL as an alternative to PGURI See #381 --- docs-new/docs/cli.md | 2 +- packages/cli/src/config.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs-new/docs/cli.md b/docs-new/docs/cli.md index 64c0a7a7..7e0c4b16 100644 --- a/docs-new/docs/cli.md +++ b/docs-new/docs/cli.md @@ -32,7 +32,7 @@ PgTyped supports common PostgreSQL environment variables: - `PGPASSWORD` - `PGDATABASE` - `PGPORT` -- `PGURI` +- `PGURI` or `DATABASE_URL` These variables will override values provided in `config.json`. diff --git a/packages/cli/src/config.ts b/packages/cli/src/config.ts index c796ead3..a5514e27 100644 --- a/packages/cli/src/config.ts +++ b/packages/cli/src/config.ts @@ -118,7 +118,7 @@ export function parseConfig( password: process.env.PGPASSWORD, dbName: process.env.PGDATABASE, port: process.env.PGPORT ? Number(process.env.PGPORT) : undefined, - uri: process.env.PGURI, + uri: process.env.PGURI ?? process.env.DATABASE_URL, }; const {