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

Function initializeDirenv

cli/src/init/init-direnv.ts:103–133  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

101
102/** Load direnv environment into process.env. Safe to call even if direnv is not installed. */
103export function initializeDirenv(): void {
104 if (!isDirenvAvailable()) {
105 return
106 }
107
108 const envrcDir = findEnvrcDirectory(process.cwd())
109 if (!envrcDir) {
110 return
111 }
112
113 const envVars = getDirenvExport(envrcDir)
114 if (!envVars) {
115 return
116 }
117 let appliedCount = 0
118 for (const [key, value] of Object.entries(envVars)) {
119 if (value === null) {
120 delete process.env[key]
121 } else {
122 process.env[key] = value
123 }
124 appliedCount++
125 }
126
127 if (appliedCount > 0) {
128 logger.debug(
129 { envrcDir, variableCount: appliedCount },
130 'Loaded environment variables from direnv',
131 )
132 }
133}

Callers 2

initializeAppFunction · 0.90

Calls 3

isDirenvAvailableFunction · 0.85
findEnvrcDirectoryFunction · 0.85
getDirenvExportFunction · 0.85

Tested by

no test coverage detected