Skip to content

Commit c4d3afa

Browse files
author
Mathusan Selvarajah
committed
autoinit- inject hostnames of other emulators into the app hosting emulator
1 parent a90eee0 commit c4d3afa

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/emulator/apphosting/serve.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ import { logger } from "./developmentServer";
1212
import { Emulators } from "../types";
1313
import { getLocalAppHostingConfiguration } from "./config";
1414
import { resolveProjectPath } from "../../projectPath";
15+
import { EmulatorRegistry } from "../registry";
16+
import { setEnvVarsForEmulators } from "../env";
1517

1618
interface StartOptions {
1719
port?: number;
@@ -55,6 +57,7 @@ async function serve(
5557
}
5658

5759
const environmentVariablesToInject = {
60+
...getEmulatorEnvs(),
5861
...environmentVariablesAsRecord,
5962
PORT: port.toString(),
6063
};
@@ -81,3 +84,12 @@ function availablePort(host: string, port: number): Promise<boolean> {
8184
family: isIPv4(host) ? "IPv4" : "IPv6",
8285
});
8386
}
87+
88+
function getEmulatorEnvs(): Record<string, string> {
89+
const envs: Record<string, string> = {};
90+
let emulatorInfos = EmulatorRegistry.listRunningWithInfo();
91+
92+
setEnvVarsForEmulators(envs, emulatorInfos);
93+
94+
return envs;
95+
}

0 commit comments

Comments
 (0)