File tree Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Original file line number Diff line number Diff line change 1+ function isTestEnvironment ( ) {
2+ // eslint-disable-next-line no-use-before-define
3+ return getConfig ( 'NODE_ENV' , { warn : false } ) === 'test' ;
4+ }
5+
16/**
27 * Returns config item from environment
38 */
4- export default function getConfig ( key ) {
9+ function getConfig ( key , options = { warn : ! isTestEnvironment ( ) } ) {
510 if ( key == null ) {
611 throw new Error ( '"key" must be provided to getConfig()' ) ;
712 }
813
9- const __process = ( typeof global !== 'undefined' ? global : window ) . process ;
10- const value = __process . env [ key ] ;
14+ const env = ( typeof global !== 'undefined' ? global : window ) ? .process ?. env || { } ;
15+ const value = env [ key ] ;
1116
12- if ( value == null ) {
17+ if ( value == null && options ?. warn !== false ) {
1318 console . warn ( `getConfig("${ key } ") returned null` ) ;
1419 }
1520
1621 return value ;
1722}
23+
24+ export default getConfig ;
You can’t perform that action at this time.
0 commit comments