File tree Expand file tree Collapse file tree 1 file changed +16
-1
lines changed
packages/database/src/core Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -28,6 +28,16 @@ import { RepoInfo } from './RepoInfo';
28
28
/** @const {string} */
29
29
const DATABASE_URL_OPTION = 'databaseURL' ;
30
30
31
+ /**
32
+ * This variable is also defined in the firebase node.js admin SDK. Before
33
+ * modifying this definition, consult the definition in:
34
+ *
35
+ * https://github.com/firebase/firebase-admin-node
36
+ *
37
+ * and make sure the two are consistent.
38
+ */
39
+ const FIREBASE_DATABASE_EMULATOR_HOST_VAR = 'FIREBASE_DATABASE_EMULATOR_HOST' ;
40
+
31
41
let _staticInstance : RepoManager ;
32
42
33
43
/**
@@ -80,7 +90,12 @@ export class RepoManager {
80
90
* @return {!Database }
81
91
*/
82
92
databaseFromApp ( app : FirebaseApp , url ?: string ) : Database {
83
- const dbUrl : string = url || app . options [ DATABASE_URL_OPTION ] ;
93
+ let dbEmulatorHost = process . env [ FIREBASE_DATABASE_EMULATOR_HOST_VAR ] ;
94
+ if ( dbEmulatorHost ) {
95
+ dbEmulatorHost = `http://${ dbEmulatorHost } ` ;
96
+ }
97
+ const dbUrl : string =
98
+ url || dbEmulatorHost || app . options [ DATABASE_URL_OPTION ] ;
84
99
if ( dbUrl === undefined ) {
85
100
fatal (
86
101
"Can't determine Firebase Database URL. Be sure to include " +
You can’t perform that action at this time.
0 commit comments