From 37c93a1f5aac574e28440f0baf7117e5f331e63c Mon Sep 17 00:00:00 2001 From: Chris Date: Wed, 25 Sep 2024 10:57:19 +0200 Subject: [PATCH] fix: filter entry points --- src/index.ts | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/index.ts b/src/index.ts index 1ce2600..b0d5cbf 100644 --- a/src/index.ts +++ b/src/index.ts @@ -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, }) @@ -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}`) } })