File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed
Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -22,6 +22,24 @@ const addEnvToProcess = (key,value) => {
2222}
2323/*eslint-enable */
2424
25+ const setUpProcessVariables = ( ) => {
26+ try {
27+ const pkg = require ( cwdPath ( 'package.json' ) ) || { }
28+ if ( pkg . scripts && pkg . scripts . start )
29+ pkg . scripts . start . split ( ' ' )
30+ . map ( x => x . split ( '=' ) )
31+ . filter ( x => x . length == 2 )
32+ . forEach ( x => { process . env [ x [ 0 ] ] = x [ 1 ] } )
33+ }
34+ catch ( err ) {
35+ console . error ( err . message )
36+ }
37+ }
38+ // This guarentees that any environment variables defined in the package.json's start scripts get assigned even
39+ // if the package.json's start script is not executed (which is the case with FaaS like Google Cloud Functions
40+ // or AWS Lambda)
41+ setUpProcessVariables ( )
42+
2543let _appconfig = null
2644const getAppConfig = memoize => {
2745 const skipMemoization = memoize == undefined ? false : ! memoize
You can’t perform that action at this time.
0 commit comments