Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
Makisuo committed Jan 19, 2025
1 parent 723a401 commit a62d6df
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
11 changes: 8 additions & 3 deletions src/commands/add.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand All @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion src/commands/diff.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ export const diff = async (...args: string[]) => {
})

await add({
component: selectedComponents.join(" "),
components: selectedComponents,
overwrite: true,
successMessage: "Updating components...",
})
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ program
.option("--skip <type>", "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 () => {
Expand Down

0 comments on commit a62d6df

Please sign in to comment.