diff --git a/src/cli.ts b/src/cli.ts index 0598d68..62177e5 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -4,11 +4,17 @@ import path from 'path' import { promises as fs } from 'fs' import { Pool } from 'pg' +const dotenvPath = process.env.DOTENV_CONFIG_PATH || '.env' + /** * Load Dotenv if the module exists. */ try { - require('dotenv').config() + require('dotenv').config({ + debug: !!process.env.DOTENV_CONFIG_DEBUG, + path: dotenvPath, + encoding: process.env.DOTENV_CONFIG_ENCODING, + }) } catch {} const { DATABASE_URL } = process.env @@ -18,7 +24,7 @@ if (!DATABASE_URL) { Please specify DATABASE_URL to run this CLi. Try the following: - Run \`DATABASE_URL=postgres://user:password@host:port/database && npm run kysely-migration-cli\` - - Place .env file containing \`DATABASE_URL=postgres://user:password@host:port/database\` + - Place ${dotenvPath} file containing \`DATABASE_URL=postgres://user:password@host:port/database\` ` console.log(hint) process.exit(1)