Skip to content

Commit f698323

Browse files
Fall back to FIRESTORE_EMULATOR_HOST if FIREBASE_FIRESTORE_EMULATOR_ADDRESS is not found (#1760)
1 parent 5a615eb commit f698323

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

packages/testing/src/api/index.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,18 @@ const DATABASE_ADDRESS_DEFAULT: string = 'localhost:9000';
4343
const DATABASE_ADDRESS: string =
4444
process.env[DATABASE_ADDRESS_ENV] || DATABASE_ADDRESS_DEFAULT;
4545

46-
/** If this environment variable is set, use it for the Firestore emulator. */
47-
const FIRESTORE_ADDRESS_ENV: string = 'FIREBASE_FIRESTORE_EMULATOR_ADDRESS';
46+
/** If any of environment variable is set, use it for the Firestore emulator. */
47+
const FIRESTORE_ADDRESS_ENVS: string[] = [
48+
'FIRESTORE_EMULATOR_HOST',
49+
'FIREBASE_FIRESTORE_EMULATOR_ADDRESS'
50+
];
4851
/** The default address for the local Firestore emulator. */
4952
const FIRESTORE_ADDRESS_DEFAULT: string = 'localhost:8080';
5053
/** The actual address for the Firestore emulator */
51-
const FIRESTORE_ADDRESS: string =
52-
process.env[FIRESTORE_ADDRESS_ENV] || FIRESTORE_ADDRESS_DEFAULT;
54+
const FIRESTORE_ADDRESS: string = FIRESTORE_ADDRESS_ENVS.reduce(
55+
(addr, name) => process.env[name] || addr,
56+
FIRESTORE_ADDRESS_DEFAULT
57+
);
5358

5459
/** Passing this in tells the emulator to treat you as an admin. */
5560
const ADMIN_TOKEN = 'owner';

0 commit comments

Comments
 (0)