mirror of
https://github.com/imputnet/cobalt.git
synced 2025-12-16 04:58:53 +00:00
api/env: add subscribe() for dynamic reloads
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { getVersion } from "@imput/version-info";
|
||||
import { loadEnvs, validateEnvs } from "./core/env.js";
|
||||
import { loadEnvs, validateEnvs, onEnvChanged } from "./core/env.js";
|
||||
|
||||
const version = await getVersion();
|
||||
|
||||
@@ -18,12 +18,20 @@ export const updateEnv = (newEnv) => {
|
||||
newEnv.tunnelPort = env.tunnelPort;
|
||||
|
||||
for (const key in env) {
|
||||
if (key === 'subscribe') {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (String(env[key]) !== String(newEnv[key])) {
|
||||
changes.push(key);
|
||||
}
|
||||
env[key] = newEnv[key];
|
||||
}
|
||||
|
||||
if (changes.length) {
|
||||
onEnvChanged(changes);
|
||||
}
|
||||
|
||||
return changes;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user