@@ -124,11 +124,31 @@ function transformTagInFile(filePath) {
124124 fs . writeFileSync ( filePath , content , 'utf8' ) ;
125125}
126126
127- const filesToPatch = [ 'fesm5.js' , 'fesm2015.js' , 'directives/proxies.d.ts' ] ;
128-
129- filesToPatch . forEach ( ( f ) => {
130- transformTagInFile ( path . join ( angularPkgDir , `./${ f } ` ) ) ;
131- } ) ;
127+ const dirEntries = fs . readdirSync ( angularPkgDir , { withFileTypes : true } ) ;
128+ const fesmFiles = dirEntries
129+ . filter ( ( d ) => d . isFile ( ) && / ^ f e s m .* \. j s $ / i. test ( d . name ) )
130+ . map ( ( d ) => d . name ) ;
131+
132+ const proxiesPath = path . join ( angularPkgDir , 'directives' , 'proxies.d.ts' ) ;
133+ const extraFiles = fs . existsSync ( proxiesPath )
134+ ? [ 'directives/proxies.d.ts' ]
135+ : [ ] ;
136+
137+ const filesToPatch = [ ...fesmFiles , ...extraFiles ] ;
138+
139+ if ( filesToPatch . length === 0 ) {
140+ console . warn ( `No files matched in ${ angularPkgDir } .` ) ;
141+ } else {
142+ filesToPatch . forEach ( ( f ) => {
143+ const filePath = path . join ( angularPkgDir , f ) ;
144+ try {
145+ transformTagInFile ( filePath ) ;
146+ } catch ( err ) {
147+ console . error ( `Failed to patch: ${ f } ` ) ;
148+ console . error ( err instanceof Error ? err . message : err ) ;
149+ }
150+ } ) ;
132151
133- console . log ( `\nAngular wrapper patched successfully for "${ angular } "` ) ;
134- console . log ( `Files patched: ${ filesToPatch . join ( ', ' ) } \n` ) ;
152+ console . log ( `\nAngular wrapper patched successfully for "${ angular } "` ) ;
153+ console . log ( `Files patched: ${ filesToPatch . join ( ', ' ) } \n` ) ;
154+ }
0 commit comments