From c19c68d3b482256a6bb2b2e9af2e96e220e687ed Mon Sep 17 00:00:00 2001 From: ByungJoon Lee Date: Mon, 19 Aug 2024 16:22:48 +0900 Subject: [PATCH] fix: changed to have exclude options take precedence over comment directives --- src/modules/commands/bundling.ts | 16 +++++++++------- .../get.inline.declaration.render.data.test.ts | 8 ++++---- .../modules/getInlineDeclarationRenderData.ts | 6 ++---- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/modules/commands/bundling.ts b/src/modules/commands/bundling.ts index d3cbc6f..066d47d 100644 --- a/src/modules/commands/bundling.ts +++ b/src/modules/commands/bundling.ts @@ -85,14 +85,16 @@ export async function bundling(buildOptions: TCommandBuildOptions, bundleOption: project, filePaths, keyword: CE_INLINE_COMMENT_KEYWORD.FILE_DECLARATION_KEYWORD, - }).filter((declaration) => { - const sourceFile = project.getSourceFile(declaration.filePath); - if (sourceFile == null) { - return false; - } + }) + .filter((declaration) => !exclude.isExclude(declaration.filePath)) + .filter((declaration) => { + const sourceFile = project.getSourceFile(declaration.filePath); + if (sourceFile == null) { + return false; + } - return isDeclarationFile(sourceFile); - }); + return isDeclarationFile(sourceFile); + }); const filenames = filePaths .filter((filename) => include.isInclude(filename)) diff --git a/src/templates/modules/__tests__/get.inline.declaration.render.data.test.ts b/src/templates/modules/__tests__/get.inline.declaration.render.data.test.ts index d368eb9..a726ef2 100644 --- a/src/templates/modules/__tests__/get.inline.declaration.render.data.test.ts +++ b/src/templates/modules/__tests__/get.inline.declaration.render.data.test.ts @@ -43,7 +43,7 @@ describe('getInlineDeclarationRenderData', () => { tag: '@ctix-declaration', pos: { line: 0, column: 0, start: 0 }, workspaces: undefined, - relativePath: '../c/d/a.ts', + relativePath: '../c/d/a', extname: { origin: '.ts', render: '.js' }, }, { @@ -52,7 +52,7 @@ describe('getInlineDeclarationRenderData', () => { tag: '@ctix-declaration', pos: { line: 0, column: 0, start: 0 }, workspaces: undefined, - relativePath: '../c/e/b.ts', + relativePath: '../c/e/b', extname: { origin: '.ts', render: '.js' }, }, ]); @@ -95,7 +95,7 @@ describe('getInlineDeclarationRenderData', () => { tag: '@ctix-declaration', pos: { line: 0, column: 0, start: 0 }, workspaces: undefined, - relativePath: `./${pathe.join(process.cwd(), '/a/b/c/d/a.ts')}`, + relativePath: `./${pathe.join(process.cwd(), '/a/b/c/d/a')}`, extname: { origin: '.ts', render: '.js' }, }, { @@ -104,7 +104,7 @@ describe('getInlineDeclarationRenderData', () => { tag: '@ctix-declaration', pos: { line: 0, column: 0, start: 0 }, workspaces: undefined, - relativePath: `./${pathe.join(process.cwd(), '/a/b/c/e/b.ts')}`, + relativePath: `./${pathe.join(process.cwd(), '/a/b/c/e/b')}`, extname: { origin: '.ts', render: '.js' }, }, ]); diff --git a/src/templates/modules/getInlineDeclarationRenderData.ts b/src/templates/modules/getInlineDeclarationRenderData.ts index c61988c..91f5b2d 100644 --- a/src/templates/modules/getInlineDeclarationRenderData.ts +++ b/src/templates/modules/getInlineDeclarationRenderData.ts @@ -21,10 +21,8 @@ export function getInlineDeclarationRenderData( const relativePath = options.output != null - ? addCurrentDirPrefix( - posixRelative(options.output, pathe.join(dirname, `${basename}${extname}`)), - ) - : replaceSepToPosix(`.${path.posix.sep}${pathe.join(dirname, `${basename}${extname}`)}`); + ? addCurrentDirPrefix(posixRelative(options.output, pathe.join(dirname, basename))) + : replaceSepToPosix(`.${path.posix.sep}${pathe.join(dirname, basename)}`); return { ...declaration,