Skip to content

Commit 5d252d6

Browse files
committed
check for env at three different places
1 parent 8b09636 commit 5d252d6

2 files changed

Lines changed: 16 additions & 6 deletions

File tree

skills/cloudsql-postgres-admin/scripts/load_env.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,15 @@ function loadEnv() {
4949

5050
// Define Paths
5151
const globalPath = path.join(os.homedir(), '.gemini', 'extensions', extensionName, '.env'); // ~/.gemini/extensions/<name>/.env
52-
const localPath = path.join(projectRoot, '.env'); // .env
52+
const localPath = path.join(projectRoot, '.env'); // cloud-sql-postgresql/.env
53+
const cwdPath = path.resolve(process.cwd(), '.env'); // <cwd>/.env
5354

54-
// Merge Environments (Global < Local)
55-
const finalEnv = { ...parseEnvFile(globalPath), ...parseEnvFile(localPath) };
55+
// Merge Environments (Global < Extension Root < User Working Directory)
56+
const finalEnv = {
57+
...parseEnvFile(globalPath),
58+
...parseEnvFile(localPath),
59+
...(cwdPath !== localPath ? parseEnvFile(cwdPath) : {})
60+
};
5661

5762
// Apply to process.env without overwriting existing shell vars
5863
for (const [key, value] of Object.entries(finalEnv)) {

skills/cloudsql-postgres/scripts/load_env.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,15 @@ function loadEnv() {
4949

5050
// Define Paths
5151
const globalPath = path.join(os.homedir(), '.gemini', 'extensions', extensionName, '.env'); // ~/.gemini/extensions/<name>/.env
52-
const localPath = path.join(projectRoot, '.env'); // .env
52+
const localPath = path.join(projectRoot, '.env'); // cloud-sql-postgresql/.env
53+
const cwdPath = path.resolve(process.cwd(), '.env'); // <cwd>/.env
5354

54-
// Merge Environments (Global < Local)
55-
const finalEnv = { ...parseEnvFile(globalPath), ...parseEnvFile(localPath) };
55+
// Merge Environments (Global < Extension Root < User Working Directory)
56+
const finalEnv = {
57+
...parseEnvFile(globalPath),
58+
...parseEnvFile(localPath),
59+
...(cwdPath !== localPath ? parseEnvFile(cwdPath) : {})
60+
};
5661

5762
// Apply to process.env without overwriting existing shell vars
5863
for (const [key, value] of Object.entries(finalEnv)) {

0 commit comments

Comments
 (0)