From 0f5167e0c4563d530f5b17050b8ee7175edcc813 Mon Sep 17 00:00:00 2001 From: Christopher Pappas Date: Wed, 16 Aug 2017 10:53:06 -0700 Subject: [PATCH] Make undefined check safe --- index.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/index.js b/index.js index ecda7b3a2..77cad2a92 100644 --- a/index.js +++ b/index.js @@ -1,15 +1,19 @@ require('babel-core/register') require('coffee-script/register') - +const _ = require('underscore') const env = require('node-env-file') -if (process.env.NODE_ENV === 'test') { +const NODE_ENV = process.env.NODE_ENV + +if (NODE_ENV === 'test') { env('./.env.test') -} else if (process.env.NODE_ENV === undefined || process.env.NODE_ENV === 'development') { - // If NODE_ENV is unset, assume that it's a local setup + + // If NODE_ENV is development or unset, assume that it's a local setup +} else if (NODE_ENV === 'development' || _.isUndefined(NODE_ENV)) { env('./.env') -} else { + // Other envs: staging, production +} else { env('./.env', { raise: false }) }