From ca6678ffb1048c691dd9fe092e47e2f5e85c6ce0 Mon Sep 17 00:00:00 2001 From: Trevor Gerhardt Date: Fri, 31 Mar 2017 10:27:41 +0200 Subject: [PATCH 1/2] fix(js-transform): Don't override process.env, pass whats needed directly to envify instead. --- bin/mastarm | 2 +- lib/js-transform.js | 11 ++++++++--- lib/load-config.js | 4 ++++ 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/bin/mastarm b/bin/mastarm index 4602f31..456c8d9 100755 --- a/bin/mastarm +++ b/bin/mastarm @@ -85,7 +85,7 @@ commander const config = loadConfig(process.cwd(), commander.config, commander.env) const get = util.makeGetFn([options, commander, config.settings]) - const env = get('env') + const env = get('env') || 'development' const s3bucket = get('s3bucket') const files = util.parseEntries([...entries, ...(get('entries') || [])]) diff --git a/lib/js-transform.js b/lib/js-transform.js index 22dcc9d..ecd591e 100644 --- a/lib/js-transform.js +++ b/lib/js-transform.js @@ -5,13 +5,18 @@ const through = require('through2') const YAML = require('yamljs') const babelConfig = require('./babel-config') -const util = require('./util') module.exports = function transform ({ config, env }) { - util.configureEnvironment({config, env}) + const envvars = Object.assign({}, process.env, { + CONFIG_PATH: config.path, + MESSAGES: JSON.stringify(config.messages), + NODE_ENV: env, + SETTINGS: JSON.stringify(config.settings), + STORE: JSON.stringify(config.store) + }, config.env) return [ svgToString, @@ -22,7 +27,7 @@ module.exports = function transform ({ }), yamlTransform, babelify.configure(babelConfig(env)), - [envify(process.env), {global: true}] // Envify needs to happen last... + [envify(envvars), {global: true}] // Envify needs to happen last... ] } diff --git a/lib/load-config.js b/lib/load-config.js index 7da2349..39aa1fd 100644 --- a/lib/load-config.js +++ b/lib/load-config.js @@ -8,6 +8,10 @@ module.exports = function load (cwd, config, environment) { const env = loadYaml('env') const settings = loadYaml('settings') + Object.keys(env).forEach((key) => { + if (env[key] === null) env[key] = undefined + }) + return { env: overrideWithEnvironment(env, environment), environment, From b94af0daf52bec962e03a88eb0c7e81bfb5cfae3 Mon Sep 17 00:00:00 2001 From: Trevor Gerhardt Date: Fri, 31 Mar 2017 11:43:13 +0200 Subject: [PATCH 2/2] refactor(load-config): Remove test code. --- lib/load-config.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/lib/load-config.js b/lib/load-config.js index 39aa1fd..7da2349 100644 --- a/lib/load-config.js +++ b/lib/load-config.js @@ -8,10 +8,6 @@ module.exports = function load (cwd, config, environment) { const env = loadYaml('env') const settings = loadYaml('settings') - Object.keys(env).forEach((key) => { - if (env[key] === null) env[key] = undefined - }) - return { env: overrideWithEnvironment(env, environment), environment,