From f1fa9cdfd8142476095b76ca12176d08ad390324 Mon Sep 17 00:00:00 2001 From: mayuriphad Date: Sun, 23 Aug 2026 21:24:09 +0530 Subject: [PATCH] Fix init command persisting env var API keys into config.json --- src/commands/init.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/commands/init.ts b/src/commands/init.ts index 4861061..3225d6e 100644 --- a/src/commands/init.ts +++ b/src/commands/init.ts @@ -123,7 +123,8 @@ export async function initCommand(options: { installHook?: boolean } = {}): Prom } if (needsApiKey) { - const existingKey = existingConfig?.apiKey ?? process.env[apiKeyEnv] ?? ''; + const existingConfigKey = existingConfig?.apiKey ?? ''; + const existingKey = existingConfigKey || process.env[apiKeyEnv] || ''; const keyResult = await text(buildApiKeyPrompt(existingKey, apiKeyEnv)); if (isCancel(keyResult)) { outro('Setup cancelled.'); @@ -132,8 +133,8 @@ export async function initCommand(options: { installHook?: boolean } = {}): Prom if (keyResult) { apiKey = keyResult; - } else if (existingKey) { - apiKey = existingKey; + } else if (existingConfigKey) { + apiKey = existingConfigKey; } else { apiKey = ''; }