diff options
| author | Olcan <[email protected]> | 2025-05-13 15:36:34 -0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-05-13 15:36:34 -0700 |
| commit | 4a0f5476c0c4fbca586167c7b858b2db139c2d41 (patch) | |
| tree | 1f1d5ac58dcae8228e776e0c13143b78263337b1 /packages/server/src | |
| parent | 3be8b6dc34f00e40f2b085df91abcd18d64a503e (diff) | |
fall back to ~/.env if .env is not found in current directory or any ancestors (#338)
Diffstat (limited to 'packages/server/src')
| -rw-r--r-- | packages/server/src/config/config.ts | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/packages/server/src/config/config.ts b/packages/server/src/config/config.ts index b5f7df3d..0cf8be2a 100644 --- a/packages/server/src/config/config.ts +++ b/packages/server/src/config/config.ts @@ -8,6 +8,7 @@ import * as dotenv from 'dotenv'; import * as fs from 'node:fs'; import * as path from 'node:path'; import process from 'node:process'; +import * as os from 'node:os'; import { ToolRegistry } from '../tools/tool-registry.js'; import { LSTool } from '../tools/ls.js'; import { ReadFileTool } from '../tools/read-file.js'; @@ -97,6 +98,11 @@ function findEnvFile(startDir: string): string | null { } const parentDir = path.dirname(currentDir); if (parentDir === currentDir || !parentDir) { + // check ~/.env as fallback + const homeEnvPath = path.join(os.homedir(), '.env'); + if (fs.existsSync(homeEnvPath)) { + return homeEnvPath; + } return null; } currentDir = parentDir; |
