File tree Expand file tree Collapse file tree
packages/@tailwindcss-upgrade/src Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -120,13 +120,18 @@ export default async function migrateContents(
120120 return spliceChangesIntoString ( contents , changes )
121121}
122122
123- export async function migrate ( designSystem : DesignSystem , userConfig : Config | null , file : string ) {
123+ export async function migrate (
124+ designSystem : DesignSystem ,
125+ userConfig : Config | null ,
126+ file : string ,
127+ ) : Promise < boolean > {
124128 let fullPath = path . isAbsolute ( file ) ? file : path . resolve ( process . cwd ( ) , file )
125129 let contents = await fs . readFile ( fullPath , 'utf-8' )
126130
127131 let migrated = await migrateContents ( designSystem , userConfig , contents , extname ( file ) )
128- if ( migrated === contents ) return // Nothing changed
129- if ( migrated . trim ( ) === '' ) return // Emptied out, something went horribly wrong
132+ if ( migrated === contents ) return false // Nothing changed
133+ if ( migrated . trim ( ) === '' ) return false // Emptied out, something went horribly wrong
130134
131135 await writeFileSafely ( fullPath , migrated )
136+ return true
132137}
Original file line number Diff line number Diff line change @@ -400,23 +400,26 @@ async function run() {
400400 }
401401
402402 // Migrate each file
403+ let changes = 0
403404 await Promise . allSettled (
404- filesToMigrate . map ( ( file ) =>
405- migrateTemplate ( designSystem , config ?. userConfig ?? null , file ) ,
406- ) ,
405+ filesToMigrate . map ( async ( file ) => {
406+ let changed = await migrateTemplate ( designSystem , config ?. userConfig ?? null , file )
407+ if ( changed ) {
408+ changes ++
409+ info ( `Migrated ${ highlight ( relative ( file , base ) ) } ` , { prefix : '↳ ' } )
410+ }
411+ } ) ,
407412 )
408413
409414 if ( config ?. configFilePath ) {
410415 success (
411- `Migrated templates for configuration file: ${ highlight ( relative ( config . configFilePath , base ) ) } ` ,
416+ `Migrated templates for configuration file: ${ highlight ( relative ( config . configFilePath , base ) ) } ( ${ changes } file ${ changes === 1 ? '' : 's' } changed) ` ,
412417 { prefix : '↳ ' } ,
413418 )
414419 } else {
415420 success (
416- `Migrated templates for: ${ highlight ( relative ( sheet . file ?? '<unknown>' , base ) ) } ` ,
417- {
418- prefix : '↳ ' ,
419- } ,
421+ `Migrated templates for: ${ highlight ( relative ( sheet . file ?? '<unknown>' , base ) ) } (${ changes } file${ changes === 1 ? '' : 's' } changed)` ,
422+ { prefix : '↳ ' } ,
420423 )
421424 }
422425 }
You can’t perform that action at this time.
0 commit comments