MCPcopy Create free account
hub / github.com/anus-dev/ANUS / findEnvFile

Function findEnvFile

packages/cli/src/config/settings.ts:202–229  ·  view source on GitHub ↗
(startDir: string)

Source from the content-addressed store, hash-verified

200}
201
202function findEnvFile(startDir: string): string | null {
203 let currentDir = path.resolve(startDir);
204 while (true) {
205 // Check for .env under ANUS_DIR only
206 const anusEnvPath = path.join(currentDir, ANUS_DIR, '.env');
207 if (fs.existsSync(anusEnvPath)) {
208 return anusEnvPath;
209 }
210 const envPath = path.join(currentDir, '.env');
211 if (fs.existsSync(envPath)) {
212 return envPath;
213 }
214 const parentDir = path.dirname(currentDir);
215 if (parentDir === currentDir || !parentDir) {
216 // check .env under home as fallback
217 const homeAnusEnvPath = path.join(homedir(), ANUS_DIR, '.env');
218 if (fs.existsSync(homeAnusEnvPath)) {
219 return homeAnusEnvPath;
220 }
221 const homeEnvPath = path.join(homedir(), '.env');
222 if (fs.existsSync(homeEnvPath)) {
223 return homeEnvPath;
224 }
225 return null;
226 }
227 currentDir = parentDir;
228 }
229}
230
231export function setUpCloudShellEnvironment(envFilePath: string | null): void {
232 // Special handling for GOOGLE_CLOUD_PROJECT in Cloud Shell:

Callers 1

loadEnvironmentFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected