Skip to content

Commit 37c93a1

Browse files
committed
fix: filter entry points
1 parent 9081b61 commit 37c93a1

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

src/index.ts

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -102,15 +102,19 @@ export async function generate(entryPoints: string | string[], options?: DtsOpti
102102

103103
const host = ts.createCompilerHost(compilerOptions)
104104

105-
// console.log('Debug:', {
106-
// cwd,
107-
// rootDir,
108-
// outDir,
109-
// entryPoints: Array.isArray(entryPoints) ? entryPoints : [entryPoints],
110-
// })
105+
// Filter entry points to only include files within the current package
106+
const filteredEntryPoints = (Array.isArray(entryPoints) ? entryPoints : [entryPoints]).filter((entryPoint) => {
107+
const relativePath = p.relative(cwd, entryPoint)
108+
return !relativePath.startsWith('..') && !p.isAbsolute(relativePath)
109+
})
110+
111+
if (filteredEntryPoints.length === 0) {
112+
console.warn('No valid entry points found within the current package.')
113+
return
114+
}
111115

112116
const program = ts.createProgram({
113-
rootNames: Array.isArray(entryPoints) ? entryPoints : [entryPoints],
117+
rootNames: filteredEntryPoints,
114118
options: compilerOptions,
115119
host,
116120
})
@@ -123,7 +127,6 @@ export async function generate(entryPoints: string | string[], options?: DtsOpti
123127
fs.mkdirSync(dir, { recursive: true })
124128
}
125129
fs.writeFileSync(outputPath, data)
126-
// console.log(`Generated: ${outputPath}`)
127130
}
128131
})
129132

0 commit comments

Comments
 (0)