MCPcopy Index your code
hub / github.com/CodebuffAI/codebuff / loadEnvFile

Function loadEnvFile

agents/e2e/base-deep.e2e.test.ts:26–51  ·  view source on GitHub ↗
(filePath: string)

Source from the content-addressed store, hash-verified

24 const traceDir = path.resolve(process.cwd(), 'e2e-traces', 'base-deep')
25
26 const loadEnvFile = async (filePath: string) => {
27 try {
28 const content = await fs.promises.readFile(filePath, 'utf-8')
29 for (const rawLine of content.split('\n')) {
30 const line = rawLine.trim()
31 if (!line || line.startsWith('#')) continue
32 const normalized = line.startsWith('export ')
33 ? line.slice('export '.length)
34 : line
35 const equalsIndex = normalized.indexOf('=')
36 if (equalsIndex <= 0) continue
37 const key = normalized.slice(0, equalsIndex).trim()
38 if (!key || process.env[key]) continue
39 let value = normalized.slice(equalsIndex + 1).trim()
40 if (
41 (value.startsWith('"') && value.endsWith('"')) ||
42 (value.startsWith("'") && value.endsWith("'"))
43 ) {
44 value = value.slice(1, -1)
45 }
46 process.env[key] = value
47 }
48 } catch {
49 // ignore missing env files
50 }
51 }
52
53 const getApiKeyOrSkip = (): string | null => {
54 const apiKey =

Callers 1

Calls 1

readFileMethod · 0.80

Tested by

no test coverage detected