mirror of
https://github.com/QwenLM/qwen-code.git
synced 2026-05-01 05:00:46 +00:00
fall back to ~/.env if .env is not found in current directory or any ancestors (#338)
This commit is contained in:
parent
3be8b6dc34
commit
4a0f5476c0
2 changed files with 14 additions and 1 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue