Skip to content

Commit

Permalink
fix: filter entry points
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisbbreuer committed Sep 25, 2024
1 parent 9081b61 commit 37c93a1
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,19 @@ export async function generate(entryPoints: string | string[], options?: DtsOpti

const host = ts.createCompilerHost(compilerOptions)

// console.log('Debug:', {
// cwd,
// rootDir,
// outDir,
// entryPoints: Array.isArray(entryPoints) ? entryPoints : [entryPoints],
// })
// Filter entry points to only include files within the current package
const filteredEntryPoints = (Array.isArray(entryPoints) ? entryPoints : [entryPoints]).filter((entryPoint) => {
const relativePath = p.relative(cwd, entryPoint)
return !relativePath.startsWith('..') && !p.isAbsolute(relativePath)
})

if (filteredEntryPoints.length === 0) {
console.warn('No valid entry points found within the current package.')
return
}

const program = ts.createProgram({
rootNames: Array.isArray(entryPoints) ? entryPoints : [entryPoints],
rootNames: filteredEntryPoints,
options: compilerOptions,
host,
})
Expand All @@ -123,7 +127,6 @@ export async function generate(entryPoints: string | string[], options?: DtsOpti
fs.mkdirSync(dir, { recursive: true })
}
fs.writeFileSync(outputPath, data)
// console.log(`Generated: ${outputPath}`)
}
})

Expand Down

0 comments on commit 37c93a1

Please sign in to comment.