Skip to content

Commit 89001ce

Browse files
committed
When env JSON cannot be parsed, return empty object.
1 parent a8f3461 commit 89001ce

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ function runtimeEnv() {
1313
try {
1414
env = JSON.parse(templatedEnv);
1515
} catch(error) {
16+
env = {};
1617
console.error(
1718
'Runtime env vars cannot be parsed. '+
1819
'Content is `'+templatedEnv+'`'

test/production-test.js

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

12-
it('continues when env JSON is not rendered (writes to error log)', function() {
13-
runtimeEnv.should.not.throw()
12+
it('continues when env JSON is not parseable (writes to error log)', function() {
13+
runtimeEnv().should.be.an.instanceOf(Object)
1414
})
1515

1616
describe('with env JSON', function() {

0 commit comments

Comments
 (0)