From 25265b556052f47d7b1134b9e3d788c8ef0c27f8 Mon Sep 17 00:00:00 2001 From: garrettmills Date: Thu, 31 Mar 2022 15:53:36 -0500 Subject: [PATCH] Only load .env if the file exists; bump version --- package.json | 2 +- src/lifecycle/Application.ts | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index a439566..0599b92 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@extollo/lib", - "version": "0.9.21", + "version": "0.9.22", "description": "The framework library that lifts up your code.", "main": "lib/index.js", "types": "lib/index.d.ts", diff --git a/src/lifecycle/Application.ts b/src/lifecycle/Application.ts index 63312d9..1be876a 100644 --- a/src/lifecycle/Application.ts +++ b/src/lifecycle/Application.ts @@ -16,6 +16,7 @@ import { import {Logging} from '../service/Logging' import {RunLevelErrorHandler} from './RunLevelErrorHandler' import {Unit, UnitStatus} from './Unit' +import * as fs from 'fs' import * as dotenv from 'dotenv' import {CacheFactory} from '../support/cache/CacheFactory' @@ -242,9 +243,12 @@ export class Application extends Container { */ protected bootstrapEnvironment(): void { logIfDebugging('extollo.env', `.env path: ${this.basePath.concat('.env').toLocal}`) - dotenv.config({ - path: this.basePath.concat('.env').toLocal, - }) + const path = this.basePath.concat('.env').toLocal + if ( fs.existsSync(path) ) { + dotenv.config({ + path, + }) + } logIfDebugging('extollo.env', process.env) }