MCPcopy Create free account
hub / github.com/EvoMap/evolver / withHubEnv

Function withHubEnv

test/proxyHubUrlDefault.test.js:11–24  ·  view source on GitHub ↗
(overrides, fn)

Source from the content-addressed store, hash-verified

9// Save/restore every env var resolveHubUrl() consults so cases don't leak.
10const HUB_ENV = ['A2A_HUB_URL', 'EVOMAP_HUB_URL', 'EVOLVER_DEFAULT_HUB_URL', 'EVOMAP_HUB_ALLOW_INSECURE'];
11function withHubEnv(overrides, fn) {
12 const saved = {};
13 for (const k of HUB_ENV) saved[k] = process.env[k];
14 for (const k of HUB_ENV) delete process.env[k];
15 for (const [k, v] of Object.entries(overrides)) process.env[k] = v;
16 try {
17 return fn();
18 } finally {
19 for (const k of HUB_ENV) {
20 if (saved[k] === undefined) delete process.env[k];
21 else process.env[k] = saved[k];
22 }
23 }
24}
25
26// evolver#567: a freshly-constructed proxy with no explicit Hub URL must default
27// to the canonical public Hub instead of '' (hub-less/offline). Previously the

Callers 1

Calls 1

fnFunction · 0.70

Tested by

no test coverage detected