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

Function loadEnvValue

sdk/src/__tests__/researcher-web.integration.test.ts:16–34  ·  view source on GitHub ↗
(name: string)

Source from the content-addressed store, hash-verified

14const EXPECTED_KEYWORD = 'useActionState'
15
16function loadEnvValue(name: string): string | undefined {
17 if (process.env[name] && process.env[name] !== 'test') {
18 return process.env[name]
19 }
20
21 for (const envPath of [
22 path.join(homedir(), 'codebuff', '.env.local'),
23 path.join(process.cwd(), '.env.local'),
24 ]) {
25 if (!existsSync(envPath)) continue
26
27 const contents = readFileSync(envPath, 'utf8')
28 const match = contents.match(new RegExp(`^${name}=(.*)$`, 'm'))
29 const value = match?.[1]?.trim().replace(/^['"]|['"]$/g, '')
30 if (value && value !== 'test') return value
31 }
32
33 return undefined
34}
35
36function extractOutputText(output: AgentOutput): string {
37 if (output.type === 'error') return output.message

Calls

no outgoing calls

Tested by

no test coverage detected