Skip to content

Commit 0fcaf5d

Browse files
authored
emulators:exec support for Storage emulator (#3337)
1 parent 5156363 commit 0fcaf5d

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/emulator/commandUtils.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,15 @@ async function runScript(script: string, extraEnv: Record<string, string>): Prom
331331
env[FirestoreEmulator.FIRESTORE_EMULATOR_ENV_ALT] = address;
332332
}
333333

334+
const storageInstance = EmulatorRegistry.get(Emulators.STORAGE);
335+
if (storageInstance) {
336+
const info = storageInstance.getInfo();
337+
const address = EmulatorRegistry.getInfoHostString(info);
338+
339+
env[Constants.FIREBASE_STORAGE_EMULATOR_HOST] = address;
340+
env[Constants.CLOUD_STORAGE_EMULATOR_HOST] = `http://${address}`;
341+
}
342+
334343
const authInstance = EmulatorRegistry.get(Emulators.AUTH);
335344
if (authInstance) {
336345
const info = authInstance.getInfo();

src/emulator/constants.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ export class Constants {
6363
static FIREBASE_STORAGE_EMULATOR_HOST = "FIREBASE_STORAGE_EMULATOR_HOST";
6464

6565
// Environment variable to override SDK/CLI to point at the Firebase Storage emulator
66-
// for firebase-admin <= 9.6.0
66+
// for firebase-admin <= 9.6.0. Unlike the FIREBASE_STORAGE_EMULATOR_HOST variable
67+
// this one must start with 'http://'.
6768
static CLOUD_STORAGE_EMULATOR_HOST = "STORAGE_EMULATOR_HOST";
6869

6970
// Environment variable to discover the Emulator HUB

0 commit comments

Comments
 (0)