diff --git a/app/config.js b/ts/node/config.ts similarity index 77% rename from app/config.js rename to ts/node/config.ts index 6c784183f..b1ed7004f 100644 --- a/app/config.js +++ b/ts/node/config.ts @@ -1,11 +1,12 @@ -const path = require('path'); +import path from 'path'; -const isDevelopment = require('electron-is-dev'); +import electronIsDev from 'electron-is-dev'; +// tslint:disable: no-console let environment; // In production mode, NODE_ENV cannot be customized by the user -if (isDevelopment) { +if (electronIsDev) { environment = process.env.NODE_ENV || 'development'; } else { environment = 'production'; @@ -18,25 +19,25 @@ process.env.NODE_CONFIG_DIR = path.join(__dirname, '..', 'config'); if (environment === 'production') { // harden production config against the local env process.env.NODE_CONFIG = ''; - process.env.NODE_CONFIG_STRICT_MODE = !isDevelopment; + process.env.NODE_CONFIG_STRICT_MODE = `${!electronIsDev}`; process.env.HOSTNAME = ''; process.env.ALLOW_CONFIG_MUTATIONS = ''; process.env.SUPPRESS_NO_CONFIG_WARNING = ''; // We could be running againt production but still be in dev mode, we need to handle that - if (!isDevelopment) { + if (!electronIsDev) { process.env.NODE_APP_INSTANCE = ''; } } // We load config after we've made our modifications to NODE_ENV -const config = require('config'); +import c from 'config'; -config.environment = environment; +(c as any).environment = environment; // Log resulting env vars in use by config ['NODE_ENV', 'NODE_APP_INSTANCE', 'NODE_CONFIG_DIR', 'NODE_CONFIG'].forEach(s => { console.log(`${s} ${config.util.getEnv(s)}`); }); -module.exports = config; +export const config = c;