From c826b86417a2229c0431c07e348314c68b4c966d Mon Sep 17 00:00:00 2001 From: Yann Braga Date: Mon, 6 Jan 2025 12:54:02 +0100 Subject: [PATCH] CLI: Fix add command not respecting --yes flag when addon is already installed --- code/lib/cli-storybook/src/add.ts | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/code/lib/cli-storybook/src/add.ts b/code/lib/cli-storybook/src/add.ts index d8df0813905d..8ba600883e7e 100644 --- a/code/lib/cli-storybook/src/add.ts +++ b/code/lib/cli-storybook/src/add.ts @@ -111,17 +111,19 @@ export async function add( let shouldAddToMain = true; if (checkInstalled(addonName, requireMain(configDir))) { - const { shouldForceInstall } = await prompts({ - type: 'confirm', - name: 'shouldForceInstall', - message: `The Storybook addon "${addonName}" is already present in ${mainConfig}. Do you wish to install it again?`, - }); - - if (!shouldForceInstall) { - return; - } - shouldAddToMain = false; + if (!yes) { + logger.log(`The Storybook addon "${addonName}" is already present in ${mainConfig}.`); + const { shouldForceInstall } = await prompts({ + type: 'confirm', + name: 'shouldForceInstall', + message: `Do you wish to install it again?`, + }); + + if (!shouldForceInstall) { + return; + } + } } const main = await readConfig(mainConfig);