File tree Expand file tree Collapse file tree 2 files changed +7
-9
lines changed Expand file tree Collapse file tree 2 files changed +7
-9
lines changed Original file line number Diff line number Diff line change 11// Capture environment as module variable to allow testing.
22var 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.
44var 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
Original file line number Diff line number Diff 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 ( / R u n t i m e e n v v a r s c o u l d n o t b e p a r s e d / )
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 } )
You can’t perform that action at this time.
0 commit comments