From b03d24217f8ff5a56ddf19c019d10b48afec813f Mon Sep 17 00:00:00 2001 From: pbaum83 Date: Sun, 17 Jan 2021 11:47:33 -0600 Subject: [PATCH] feat: add command parameter to set custom dotenv conf (#1590) --- src/config.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/config.ts b/src/config.ts index 9380b238e7..24ea997089 100644 --- a/src/config.ts +++ b/src/config.ts @@ -3,7 +3,17 @@ import {banner} from './banner'; import dotenv from 'dotenv'; import path from 'path'; -if (existsSync(path.resolve(__dirname, '../dotenv'))) { +if (process.env.npm_config_conf) { + if ( + existsSync(path.resolve(__dirname, '../' + process.env.npm_config_conf)) + ) { + dotenv.config({ + path: path.resolve(__dirname, '../' + process.env.npm_config_conf) + }); + } else { + dotenv.config({path: path.resolve(__dirname, '../.env')}); + } +} else if (existsSync(path.resolve(__dirname, '../dotenv'))) { dotenv.config({path: path.resolve(__dirname, '../dotenv')}); } else { dotenv.config({path: path.resolve(__dirname, '../.env')});