(filePath: string)
| 81 | } |
| 82 | |
| 83 | const loadEnvFile = async (filePath: string) => { |
| 84 | try { |
| 85 | const content = await fs.promises.readFile(filePath, 'utf-8') |
| 86 | for (const rawLine of content.split('\n')) { |
| 87 | const line = rawLine.trim() |
| 88 | if (!line || line.startsWith('#')) continue |
| 89 | const normalized = line.startsWith('export ') |
| 90 | ? line.slice('export '.length) |
| 91 | : line |
| 92 | const equalsIndex = normalized.indexOf('=') |
| 93 | if (equalsIndex <= 0) continue |
| 94 | const key = normalized.slice(0, equalsIndex).trim() |
| 95 | if (!key || process.env[key]) continue |
| 96 | let value = normalized.slice(equalsIndex + 1).trim() |
| 97 | if ( |
| 98 | (value.startsWith('"') && value.endsWith('"')) || |
| 99 | (value.startsWith("'") && value.endsWith("'")) |
| 100 | ) { |
| 101 | value = value.slice(1, -1) |
| 102 | } |
| 103 | process.env[key] = value |
| 104 | } |
| 105 | } catch { |
| 106 | // ignore missing env files |
| 107 | } |
| 108 | } |
| 109 | |
| 110 | /** |
| 111 | * Creates a pre-summarized conversation that mimics what the context pruner produces. |
no test coverage detected