diff --git a/src/commands/add.ts b/src/commands/add.ts index 12d280d..5b8578c 100644 --- a/src/commands/add.ts +++ b/src/commands/add.ts @@ -91,9 +91,13 @@ async function updateIndexFile( * This function is used to add new components to the project * @param options any */ -export async function add(options: any) { +export async function add(options: { + components: string[] + overwrite: boolean + successMessage: string +}) { const spinner = ora("Checking.").start() - const { component, overwrite, successMessage } = options + const { overwrite, successMessage, components: comps } = options const doesConfigExist = await configManager.doesConfigExist() @@ -109,7 +113,8 @@ export async function add(options: any) { spinner.stop() const exclude = ["primitive"] - let selectedComponents = component ? component.split(" ") : [] + let selectedComponents = comps + if (selectedComponents.length === 0) { const choices = components .filter((comp) => !exclude.includes(comp.name)) diff --git a/src/commands/diff.ts b/src/commands/diff.ts index e8c4f5a..83d3fd1 100644 --- a/src/commands/diff.ts +++ b/src/commands/diff.ts @@ -196,7 +196,7 @@ export const diff = async (...args: string[]) => { }) await add({ - component: selectedComponents.join(" "), + components: selectedComponents, overwrite: true, successMessage: "Updating components...", }) diff --git a/src/index.ts b/src/index.ts index 345c2f3..7881676 100644 --- a/src/index.ts +++ b/src/index.ts @@ -63,7 +63,7 @@ program .option("--skip ", "Skip") .option("-o, --overwrite", "Override existing components") .action(async (components, options) => { - await add({ component: components.join(" "), ...options }) + await add({ components, ...options }) }) program.command("login").action(async () => {