Harden production against NODE_ENV environment variable (#2010)

Fixes #1999
This commit is contained in:
Scott Nonnenberg 2018-01-29 16:57:49 -08:00 committed by GitHub
parent 9d9991e0f3
commit 3f0354f09e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -2,8 +2,14 @@ const path = require('path');
const electronIsDev = require('electron-is-dev');
const defaultEnvironment = electronIsDev ? 'development' : 'production';
const environment = process.env.NODE_ENV || defaultEnvironment;
let environment;
// In production mode, NODE_ENV cannot be customized by the user
if (electronIsDev) {
environment = process.env.NODE_ENV || 'development';
} else {
environment = 'production';
}
// Set environment vars to configure node-config before requiring it
process.env.NODE_ENV = environment;