From 75115442effbf4739c495cc2593efb36518e6bdb Mon Sep 17 00:00:00 2001 From: Sam Date: Thu, 6 May 2021 10:29:05 +0100 Subject: [PATCH] emulators:exec support for Storage emulator --- src/emulator/commandUtils.ts | 9 +++++++++ src/emulator/constants.ts | 3 ++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/emulator/commandUtils.ts b/src/emulator/commandUtils.ts index 9d77a3d4855..daf392e4c78 100644 --- a/src/emulator/commandUtils.ts +++ b/src/emulator/commandUtils.ts @@ -331,6 +331,15 @@ async function runScript(script: string, extraEnv: Record): Prom env[FirestoreEmulator.FIRESTORE_EMULATOR_ENV_ALT] = address; } + const storageInstance = EmulatorRegistry.get(Emulators.STORAGE); + if (storageInstance) { + const info = storageInstance.getInfo(); + const address = EmulatorRegistry.getInfoHostString(info); + + env[Constants.FIREBASE_STORAGE_EMULATOR_HOST] = address; + env[Constants.CLOUD_STORAGE_EMULATOR_HOST] = `http://${address}`; + } + const authInstance = EmulatorRegistry.get(Emulators.AUTH); if (authInstance) { const info = authInstance.getInfo(); diff --git a/src/emulator/constants.ts b/src/emulator/constants.ts index 45b83372cfc..4d22831325a 100644 --- a/src/emulator/constants.ts +++ b/src/emulator/constants.ts @@ -63,7 +63,8 @@ export class Constants { static FIREBASE_STORAGE_EMULATOR_HOST = "FIREBASE_STORAGE_EMULATOR_HOST"; // Environment variable to override SDK/CLI to point at the Firebase Storage emulator - // for firebase-admin <= 9.6.0 + // for firebase-admin <= 9.6.0. Unlike the FIREBASE_STORAGE_EMULATOR_HOST variable + // this one must start with 'http://'. static CLOUD_STORAGE_EMULATOR_HOST = "STORAGE_EMULATOR_HOST"; // Environment variable to discover the Emulator HUB