@@ -235,43 +235,57 @@ function createUpgradeRule() {
235235
236236function applyUpdateInContent ( tree : Tree , path : string ) {
237237 const directory = tree . getDir ( path ) ;
238- if ( directory . subfiles . length ) {
239- directory . subfiles . forEach ( file => {
240- const filePath = path + '/' + file ;
241- // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
242- const content = tree . read ( filePath ) ! . toString ( 'utf-8' ) ;
243- if ( ! content ) {
244- return ;
245- }
246238
247- let updated = content ;
239+ // Função recursiva para processar arquivos e subdiretórios
240+ const processDirectory = ( dir : any ) => {
241+ // Processa todos os arquivos no diretório atual
242+ if ( dir . subfiles . length ) {
243+ dir . subfiles . forEach ( ( file : string ) => {
244+ const filePath = dir . path + '/' + file ;
245+ const content = tree . read ( filePath ) ! . toString ( 'utf-8' ) ;
246+ if ( ! content ) {
247+ return ;
248+ }
248249
249- if ( file . endsWith ( '.html' ) || file . endsWith ( '.ts' ) ) {
250- //atualiza para as instancias dos novos ícones
251- updated = replaceWithChanges ( poIconInsideReplaces , updated ) ;
252- updated = replaceWithChanges ( poIconReplaces , updated ) ;
250+ let updated = content ;
253251
254- const icons = iconsReplaced . filter ( ( icon : any ) => updated . includes ( icon . replace ) ) ;
252+ if ( file . endsWith ( '.html' ) || file . endsWith ( '.ts' ) ) {
253+ // Atualiza para as instâncias dos novos ícones
254+ updated = replaceWithChanges ( poIconInsideReplaces , updated ) ;
255+ updated = replaceWithChanges ( poIconReplaces , updated ) ;
255256
256- icons . forEach ( icon => {
257- const regexChange = new RegExp ( '(class="\\s?)?' + icon . replace + '(\\s?)?(?="|>|\\s|$|\'|")' , 'gmi' ) ;
257+ const icons = iconsReplaced . filter ( ( icon : any ) => updated . includes ( icon . replace ) ) ;
258258
259- if ( icon . fill ) {
260- updated = replaceWithChanges ( [ { replace : regexChange , replaceWith : `$1${ icon . replaceWith } $2` } ] , updated ) ;
261- } else {
262- updated = replaceWithChanges (
263- [ { replace : regexChange , replaceWith : `$1ph ${ icon . replaceWith } $2` } ] ,
264- updated
265- ) ;
266- }
267- } ) ;
259+ icons . forEach ( icon => {
260+ const regexChange = new RegExp ( '(class="\\s?)?' + icon . replace + '(\\s?)?(?="|>|\\s|$|\'|")' , 'gmi' ) ;
268261
269- if ( updated !== content ) {
270- tree . overwrite ( filePath , updated ) ;
262+ if ( icon . fill ) {
263+ updated = replaceWithChanges ( [ { replace : regexChange , replaceWith : `$1${ icon . replaceWith } $2` } ] , updated ) ;
264+ } else {
265+ updated = replaceWithChanges (
266+ [ { replace : regexChange , replaceWith : `$1ph ${ icon . replaceWith } $2` } ] ,
267+ updated
268+ ) ;
269+ }
270+ } ) ;
271+
272+ if ( updated !== content ) {
273+ tree . overwrite ( filePath , updated ) ;
274+ }
271275 }
272- }
273- } ) ;
274- }
276+ } ) ;
277+ }
278+
279+ // Processa subdiretórios recursivamente
280+ if ( dir . subdirs . length ) {
281+ dir . subdirs . forEach ( ( subdir : string ) => {
282+ processDirectory ( tree . getDir ( dir . path + '/' + subdir ) ) ;
283+ } ) ;
284+ }
285+ } ;
286+
287+ // Inicia o processamento a partir do diretório especificado
288+ processDirectory ( directory ) ;
275289}
276290
277291function replaceWithChanges ( replaces : Array < ReplaceChanges > , content : string = '' ) {
0 commit comments