mirror of
https://github.com/openclaw/openclaw.git
synced 2026-07-02 10:43:37 +00:00
* fix(cron): run legacy cron store migration in gateway fast path * fix(cli): run gateway startup migrations * fix(gateway): guard startup migrations and config selection * fix(gateway): reconcile final startup environment * fix(gateway): preserve guarded startup env semantics * fix(gateway): guard service-mode recovery candidates * fix(config): reconcile normalized env precedence * fix(cli): clear replaced proxy signal handlers * fix(gateway): reject invalid final config * test(gateway): cover invalid future config reset guard * test(cli): remove unused recovery state
23 lines
952 B
TypeScript
23 lines
952 B
TypeScript
// CLI dotenv loader that preserves workspace overrides before global runtime fallbacks.
|
|
import path from "node:path";
|
|
import { resolveStateDir } from "../config/paths.js";
|
|
import { loadGlobalRuntimeDotEnvFiles, loadWorkspaceDotEnvFile } from "../infra/dotenv.js";
|
|
|
|
/** Load `.env` files for normal CLI commands without overriding existing process env. */
|
|
export function loadCliDotEnv(opts?: { loadGlobalEnv?: boolean; quiet?: boolean }) {
|
|
const quiet = opts?.quiet ?? true;
|
|
const cwdEnvPath = path.join(process.cwd(), ".env");
|
|
loadWorkspaceDotEnvFile(cwdEnvPath, { quiet });
|
|
|
|
if (opts?.loadGlobalEnv === false) {
|
|
return;
|
|
}
|
|
// Then load the global fallback set without overriding any env vars that
|
|
// were already set or loaded from CWD. This includes the Ubuntu fresh-install
|
|
// gateway.env compatibility path.
|
|
loadGlobalRuntimeDotEnvFiles({
|
|
quiet,
|
|
stateEnvPath: path.join(resolveStateDir(process.env), ".env"),
|
|
});
|
|
}
|