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

Function setUpCloudShellEnvironment

packages/cli/src/config/settings.ts:231–251  ·  view source on GitHub ↗
(envFilePath: string | null)

Source from the content-addressed store, hash-verified

229}
230
231export function setUpCloudShellEnvironment(envFilePath: string | null): void {
232 // Special handling for GOOGLE_CLOUD_PROJECT in Cloud Shell:
233 // Because GOOGLE_CLOUD_PROJECT in Cloud Shell tracks the project
234 // set by the user using "gcloud config set project" we do not want to
235 // use its value. So, unless the user overrides GOOGLE_CLOUD_PROJECT in
236 // one of the .env files, we set the Cloud Shell-specific default here.
237 if (envFilePath && fs.existsSync(envFilePath)) {
238 const envFileContent = fs.readFileSync(envFilePath);
239 const parsedEnv = dotenv.parse(envFileContent);
240 if (parsedEnv['GOOGLE_CLOUD_PROJECT']) {
241 // .env file takes precedence in Cloud Shell
242 process.env['GOOGLE_CLOUD_PROJECT'] = parsedEnv['GOOGLE_CLOUD_PROJECT'];
243 } else {
244 // If not in .env, set to default and override global
245 process.env['GOOGLE_CLOUD_PROJECT'] = 'cloudshell-gca';
246 }
247 } else {
248 // If no .env file, set to default and override global
249 process.env['GOOGLE_CLOUD_PROJECT'] = 'cloudshell-gca';
250 }
251}
252
253export function loadEnvironment(settings?: Settings): void {
254 const envFilePath = findEnvFile(process.cwd());

Callers 1

loadEnvironmentFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected