diff options
| author | Brandon Keiji <[email protected]> | 2025-04-18 10:25:32 -0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-04-18 10:25:32 -0700 |
| commit | 999d0568fab9c4da2ae0978c4344bf76fe2cb27e (patch) | |
| tree | 164e79df324d45768dd4b5f60680655f4ad625ba | |
| parent | 7878f5404327d3a050851cbebe3308cfa1850d58 (diff) | |
Refactor: Update API key missing message with link (#23)
| -rw-r--r-- | packages/cli/src/config/env.ts | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/packages/cli/src/config/env.ts b/packages/cli/src/config/env.ts index ad535b80..51fc0a9c 100644 --- a/packages/cli/src/config/env.ts +++ b/packages/cli/src/config/env.ts @@ -24,17 +24,15 @@ export function loadEnvironment(): void { // Start searching from the current working directory by default const envFilePath = findEnvFile(process.cwd()); - if (!envFilePath) { - return; + if (envFilePath) { + dotenv.config({ path: envFilePath }); } - dotenv.config({ path: envFilePath }); - - if (!process.env.GEMINI_API_KEY) { + if (!process.env.GEMINI_API_KEY?.length) { console.error( - 'Error: GEMINI_API_KEY environment variable is not set in the loaded .env file.', + 'Error: GEMINI_API_KEY environment variable is not set. Please visit https://ai.google.dev/gemini-api/docs/api-key to set up a new one.', ); - process.exit(1); + process.exit(0); } } @@ -43,7 +41,7 @@ export function getApiKey(): string { const apiKey = process.env.GEMINI_API_KEY; if (!apiKey) { throw new Error( - 'GEMINI_API_KEY is missing. Ensure loadEnvironment() was called successfully.', + 'GEMINI_API_KEY environment variable is not set. Please visit https://ai.google.dev/gemini-api/docs/api-key to set up a new one.', ); } return apiKey; |
