From caaf1ae7a83c4cdd2a0e05eb6ead4a487c039cc0 Mon Sep 17 00:00:00 2001 From: winches <329487092@qq.com> Date: Sat, 7 Dec 2024 15:15:23 +0800 Subject: [PATCH] fix: exit the process when all components added --- src/actions/add-action.ts | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/src/actions/add-action.ts b/src/actions/add-action.ts index b50c019..0a56047 100644 --- a/src/actions/add-action.ts +++ b/src/actions/add-action.ts @@ -56,20 +56,25 @@ export async function addAction(components: string[], options: AddActionOptions) const isNextUIAll = !!allDependencies[NEXT_UI]; if (!components.length && !all) { + const filteredComponents = store.nextUIComponents.filter( + (component) => + !currentComponents.some((currentComponent) => currentComponent.name === component.name) + ); + + if (!filteredComponents.length) { + Logger.success('✅ All components have been added'); + process.exit(0); + } + components = await getAutocompleteMultiselect( 'Which components would you like to add?', - store.nextUIComponents - .filter( - (component) => - !currentComponents.some((currentComponent) => currentComponent.name === component.name) - ) - .map((component) => { - return { - description: component.description, - title: component.name, - value: component.name - }; - }) + filteredComponents.map((component) => { + return { + description: component.description, + title: component.name, + value: component.name + }; + }) ); } else if (all) { components = [NEXT_UI];