Skip to content

Commit 48105b7

Browse files
authored
[code-infra] Fix build:types script omitting folders with a dot in their name (#45422)
1 parent f411820 commit 48105b7

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

scripts/buildTypes.mts

+11-5
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import path from 'path';
44
import yargs from 'yargs';
55
import { $ } from 'execa';
66
import * as babel from '@babel/core';
7-
import { typescriptCopy } from './copyFilesUtils.mjs';
87

98
const $$ = $({ stdio: 'inherit' });
109

@@ -47,9 +46,16 @@ async function copyDeclarations(sourceDirectory: string, destinationDirectory: s
4746

4847
await fs.cp(fullSourceDirectory, fullDestinationDirectory, {
4948
recursive: true,
50-
filter: (src) => {
51-
// include directories and .d.ts files
52-
return !src.includes('.') || src.endsWith('.d.ts');
49+
filter: async (src) => {
50+
if (src.startsWith('.')) {
51+
// ignore dotfiles
52+
return false;
53+
}
54+
const stats = await fs.stat(src);
55+
if (stats.isDirectory()) {
56+
return true;
57+
}
58+
return src.endsWith('.d.ts');
5359
},
5460
});
5561
}
@@ -66,7 +72,7 @@ async function main(argv: HandlerArgv) {
6672
const esmFolder = path.join(buildFolder, 'esm');
6773
const modernFolder = path.join(buildFolder, 'modern');
6874

69-
await typescriptCopy({ from: srcPath, to: esmFolder });
75+
await copyDeclarations(srcPath, esmFolder);
7076

7177
if (!argv.skipTsc) {
7278
const tsconfigPath = path.join(packageRoot, 'tsconfig.build.json');

0 commit comments

Comments
 (0)