Skip to content

Commit

Permalink
fix duplicates
Browse files Browse the repository at this point in the history
  • Loading branch information
Makisuo committed Feb 14, 2025
1 parent 7634ce0 commit 52d1b68
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/commands/add.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ async function updateIndexFile(config: Config, componentName: string, processed:
`index.${config.language === "javascript" ? "js" : "ts"}`,
)

const primitiveExport = `export * from './primitive';`
const componentExport = `export * from './${componentName}';`
const primitiveExport = `export * from './primitive'`
const componentExport = `export * from './${componentName}'`

// Use a Set to deduplicate export lines
const exportSet = new Set<string>()
Expand All @@ -46,12 +46,14 @@ async function updateIndexFile(config: Config, componentName: string, processed:
.split("\n")
.map((line) => line.trim())
.filter((line) => line !== "")
.forEach((line) => exportSet.add(line))
.forEach((line) => exportSet.add(line.replace(";", "")))
}

console.log(exportSet)

// Filter out exports related to "primitive" or names in namespaces
Array.from(exportSet).forEach((line) => {
const match = line.match(/export \* from '\.\/(.+)';/)
const match = line.match(/export \* from '\.\/(.+)'/)
const matchedComponent = match?.[1]
if (matchedComponent === "primitive" || namespaces.includes(matchedComponent ?? "")) {
exportSet.delete(line)
Expand Down

0 comments on commit 52d1b68

Please sign in to comment.