Skip to content

Commit a8f3461

Browse files
committed
Remove mustache refs; avoid throwing errors, log instead
1 parent 5e2d1f6 commit a8f3461

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

index.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Capture environment as module variable to allow testing.
22
var originalEnv = process.env;
3-
// This Mustache template tag should be rendered/replaced with the environment in production.
3+
// This template tag should be rendered/replaced with the environment in production.
44
var templatedEnv = '{{REACT_APP_VARS_AS_JSON}}';
55

66

@@ -13,11 +13,9 @@ function runtimeEnv() {
1313
try {
1414
env = JSON.parse(templatedEnv);
1515
} catch(error) {
16-
throw new Error(
17-
'Runtime env vars could not be parsed. '+
18-
'Content of `REACT_APP_VARS_AS_JSON` is `'+templatedEnv+'` '+
19-
'Ensure `node_modules/@mars/heroku-js-runtime-env/index.js` '+
20-
'is rendered as a Mustache template.'
16+
console.error(
17+
'Runtime env vars cannot be parsed. '+
18+
'Content is `'+templatedEnv+'`'
2119
);
2220
}
2321

test/production-test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ describe('in production', function() {
99
runtimeEnv.__set__('originalEnv', { NODE_ENV: 'production'})
1010
})
1111

12-
it('throws error when Mustache tag is not rendered', function() {
13-
runtimeEnv.should.throw(/Runtime env vars could not be parsed/)
12+
it('continues when env JSON is not rendered (writes to error log)', function() {
13+
runtimeEnv.should.not.throw()
1414
})
1515

16-
describe('with Mustache template replacements', function() {
16+
describe('with env JSON', function() {
1717
beforeEach(function() {
1818
runtimeEnv.__set__('templatedEnv', '{ "REACT_APP_USER": "🦄"}')
1919
})

0 commit comments

Comments
 (0)