@@ -104,11 +104,8 @@ export async function safeGlobby(
104
104
return Globby ( globPaths , options ) ;
105
105
}
106
106
107
- // A bit weird to put this here, but it's used by core + theme-translations
108
- export async function globTranslatableSourceFiles (
109
- patterns : string [ ] ,
110
- ) : Promise < string [ ] > {
111
- // We only support extracting source code translations from these kind of files
107
+ export const isTranslatableSourceFile : ( filePath : string ) => boolean = ( ( ) => {
108
+ // We only support extracting source code translations from these extensions
112
109
const extensionsAllowed = new Set ( [
113
110
'.js' ,
114
111
'.jsx' ,
@@ -120,8 +117,21 @@ export async function globTranslatableSourceFiles(
120
117
// '.mdx',
121
118
] ) ;
122
119
120
+ const isBlacklistedFilePath = ( filePath : string ) => {
121
+ // We usually extract from ts files, unless they are .d.ts files
122
+ return filePath . endsWith ( '.d.ts' ) ;
123
+ } ;
124
+
125
+ return ( filePath ) : boolean => {
126
+ const ext = path . extname ( filePath ) ;
127
+ return extensionsAllowed . has ( ext ) && ! isBlacklistedFilePath ( filePath ) ;
128
+ } ;
129
+ } ) ( ) ;
130
+
131
+ // A bit weird to put this here, but it's used by core + theme-translations
132
+ export async function globTranslatableSourceFiles (
133
+ patterns : string [ ] ,
134
+ ) : Promise < string [ ] > {
123
135
const filePaths = await safeGlobby ( patterns ) ;
124
- return filePaths . filter ( ( filePath ) =>
125
- extensionsAllowed . has ( path . extname ( filePath ) ) ,
126
- ) ;
136
+ return filePaths . filter ( isTranslatableSourceFile ) ;
127
137
}
0 commit comments