Skip to content

Commit 06de1a1

Browse files
committed
fix: do not copy declarationDir into outDir
1 parent ba0ca31 commit 06de1a1

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/copy-addon.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { red } from './log.utils'
1111
*/
1212
export default function copyOtherFiles(program: Program, emittedFiles: string[] | undefined = []) {
1313
console.log('Copying other files')
14-
const { outDir, listEmittedFiles } = program.getCompilerOptions()
14+
const { outDir, declarationDir, listEmittedFiles } = program.getCompilerOptions()
1515

1616
if (outDir == null) {
1717
console.error(red('Cannot copy: you must define `outDir` in the compiler options'))
@@ -21,8 +21,10 @@ export default function copyOtherFiles(program: Program, emittedFiles: string[]
2121
const srcDir = program.getCommonSourceDirectory()
2222
if (!srcDir) throw Error('Cannot copy: issue with internal typescript method `getCommonSourceDirectory`')
2323

24-
// Exclude typescript files and outDir if previously emitted in the same folder
25-
const otherFiles = matchAllFilesBut(srcDir, ['**/*.ts', outDir])
24+
// Exclude typescript files and outDir/declarationDir if previously emitted in the same folder
25+
const excludes = ['**/*.ts', outDir]
26+
if (declarationDir) excludes.push(declarationDir)
27+
const otherFiles = matchAllFilesBut(srcDir, excludes)
2628

2729
// Track copied files to list them later if needed
2830
const copiedFiles: string[] = []

0 commit comments

Comments
 (0)