Skip to content

Commit

Permalink
autoinit- inject hostnames of other emulators into the app hosting em…
Browse files Browse the repository at this point in the history
…ulator
  • Loading branch information
mathu97 committed Dec 13, 2024
1 parent a90eee0 commit c4d3afa
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/emulator/apphosting/serve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import { logger } from "./developmentServer";
import { Emulators } from "../types";
import { getLocalAppHostingConfiguration } from "./config";
import { resolveProjectPath } from "../../projectPath";
import { EmulatorRegistry } from "../registry";
import { setEnvVarsForEmulators } from "../env";

interface StartOptions {
port?: number;
Expand Down Expand Up @@ -55,6 +57,7 @@ async function serve(
}

const environmentVariablesToInject = {
...getEmulatorEnvs(),
...environmentVariablesAsRecord,
PORT: port.toString(),
};
Expand All @@ -81,3 +84,12 @@ function availablePort(host: string, port: number): Promise<boolean> {
family: isIPv4(host) ? "IPv4" : "IPv6",
});
}

function getEmulatorEnvs(): Record<string, string> {
const envs: Record<string, string> = {};
let emulatorInfos = EmulatorRegistry.listRunningWithInfo();

Check failure on line 90 in src/emulator/apphosting/serve.ts

View workflow job for this annotation

GitHub Actions / unit (18)

'emulatorInfos' is never reassigned. Use 'const' instead

setEnvVarsForEmulators(envs, emulatorInfos);

return envs;
}

0 comments on commit c4d3afa

Please sign in to comment.