@@ -38,21 +38,36 @@ const getDefaultsFromGlobal = (): FirebaseDefaults | undefined =>
38
38
getGlobal ( ) . __FIREBASE_DEFAULTS__ ;
39
39
40
40
/**
41
- * Attempt to read defaults from a JSON file whose path is in
41
+ * Attempt to read defaults from a JSON string provided to
42
+ * process.env.__FIREBASE_DEFAULTS__ or a JSON file whose path is in
42
43
* process.env.__FIREBASE_DEFAULTS_PATH__
43
44
*/
44
45
const getDefaultsFromEnvVariable = ( ) : FirebaseDefaults | undefined => {
45
46
if ( typeof process === 'undefined' ) {
46
47
return ;
47
48
}
48
- const jsonPath = process . env . __FIREBASE_DEFAULTS_PATH__ ;
49
- if ( jsonPath && typeof require !== 'undefined' ) {
49
+ const defaultsJsonString = process . env . __FIREBASE_DEFAULTS__ ;
50
+ const defaultsJsonPath = process . env . __FIREBASE_DEFAULTS_PATH__ ;
51
+ if ( defaultsJsonString ) {
52
+ if ( defaultsJsonPath ) {
53
+ console . warn (
54
+ `Values were provided for both __FIREBASE_DEFAULTS__ ` +
55
+ `and __FIREBASE_DEFAULTS_PATH__. __FIREBASE_DEFAULTS_PATH__ ` +
56
+ `will be ignored.`
57
+ ) ;
58
+ }
59
+ return JSON . parse ( defaultsJsonString ) ;
60
+ }
61
+ if ( defaultsJsonPath && typeof require !== 'undefined' ) {
50
62
try {
51
63
// eslint-disable-next-line @typescript-eslint/no-require-imports
52
- const json = require ( jsonPath ) ;
64
+ const json = require ( defaultsJsonPath ) ;
53
65
return json ;
54
66
} catch ( e ) {
55
- console . warn ( `Unable to read defaults from file: ${ jsonPath } .` ) ;
67
+ console . warn (
68
+ `Unable to read defaults from file provided to ` +
69
+ `__FIREBASE_DEFAULTS_PATH__: ${ defaultsJsonPath } `
70
+ ) ;
56
71
}
57
72
}
58
73
} ;
0 commit comments