mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-31 14:26:30 +02:00
* Filter untrusted CWD .env entries before OpenClaw startup * Add missing test file * Fix missing and updated files * Address feedback * Feedback updates * Feedback update * Add test coverage * Unit test fix
15 lines
639 B
TypeScript
15 lines
639 B
TypeScript
import path from "node:path";
|
|
import { resolveStateDir } from "../config/paths.js";
|
|
import { loadRuntimeDotEnvFile, loadWorkspaceDotEnvFile } from "../infra/dotenv.js";
|
|
|
|
export function loadCliDotEnv(opts?: { quiet?: boolean }) {
|
|
const quiet = opts?.quiet ?? true;
|
|
const cwdEnvPath = path.join(process.cwd(), ".env");
|
|
loadWorkspaceDotEnvFile(cwdEnvPath, { quiet });
|
|
|
|
// Then load the global fallback from the active state dir without overriding
|
|
// any env vars that were already set or loaded from CWD.
|
|
const globalEnvPath = path.join(resolveStateDir(process.env), ".env");
|
|
loadRuntimeDotEnvFile(globalEnvPath, { quiet });
|
|
}
|