@@ -102,13 +102,7 @@ function processFile(filePath: string, options: ScriptOptions) {
102
102
// Remove the legacy type property if option is passed
103
103
const removeLegacyType = Boolean ( options . removeType && data . type )
104
104
105
- // Skip if contentType already exists and we're not removing legacy type
106
- if ( data . contentType && ! removeLegacyType ) {
107
- console . log ( `contentType already set on ${ relativePath } ` )
108
- return { processed : true , updated : false }
109
- }
110
-
111
- const newContentType = data . contentType || determineContentType ( relativePath , data . type || '' )
105
+ const newContentType = determineContentType ( relativePath , data . type || '' )
112
106
113
107
if ( options . dryRun ) {
114
108
console . log ( `\n${ relativePath } ` )
@@ -121,9 +115,24 @@ function processFile(filePath: string, options: ScriptOptions) {
121
115
return { processed : true , updated : false }
122
116
}
123
117
124
- // Set the contentType property if it doesn't exist
125
- if ( ! data . contentType ) {
118
+ // Check if we're actually changing an existing contentType
119
+ const isChangingContentType = data . contentType && data . contentType !== newContentType
120
+ const isAddingContentType = ! data . contentType
121
+
122
+ if ( isChangingContentType ) {
123
+ console . log (
124
+ `Changing contentType from '${ data . contentType } ' to '${ newContentType } ' on ${ relativePath } ` ,
125
+ )
126
+ } else if ( isAddingContentType ) {
127
+ console . log ( `Adding contentType '${ newContentType } ' on ${ relativePath } ` )
128
+ }
129
+
130
+ // Only update if there's actually a change needed
131
+ if ( isChangingContentType || isAddingContentType ) {
126
132
data . contentType = newContentType
133
+ } else {
134
+ console . log ( `contentType is already set to '${ data . contentType } ' on ${ relativePath } ` )
135
+ return { processed : true , updated : false }
127
136
}
128
137
129
138
let legacyTypeValue
0 commit comments