@@ -172,7 +172,19 @@ export default class Extensions extends BaseClass {
172172 ? JSON . parse ( readFileSync ( this . extensionsPath , 'utf8' ) )
173173 : { } ;
174174 log . debug ( `Loaded ${ Object . keys ( newExtensionSchema ) . length } existing extensions` , this . config . auditContext ) ;
175-
175+
176+ let userConfirm : boolean ;
177+ if (
178+ this . config . flags [ 'copy-dir' ] ||
179+ this . config . flags [ 'external-config' ] ?. skipConfirm ||
180+ this . config . flags . yes
181+ ) {
182+ userConfirm = true ;
183+ } else {
184+ this . completeProgress ( true ) ;
185+ userConfirm = await cliux . confirm ( commonMsg . FIX_CONFIRMATION ) ;
186+ }
187+
176188 for ( const ext of missingCtInExtensions ) {
177189 const { uid, title } = ext ;
178190 log . debug ( `Fixing extension: ${ title } (${ uid } )` , this . config . auditContext ) ;
@@ -187,8 +199,7 @@ export default class Extensions extends BaseClass {
187199 } else {
188200 log . debug ( `Extension ${ title } has no valid content types or scope not found` , this . config . auditContext ) ;
189201 cliux . print ( $t ( commonMsg . EXTENSION_FIX_WARN , { title : title , uid } ) , { color : 'yellow' } ) ;
190- const shouldDelete = this . config . flags . yes || ( await cliux . confirm ( commonMsg . EXTENSION_FIX_CONFIRMATION ) ) ;
191- if ( shouldDelete ) {
202+ if ( userConfirm ) {
192203 log . debug ( `Deleting extension: ${ title } (${ uid } )` , this . config . auditContext ) ;
193204 delete newExtensionSchema [ uid ] ;
194205 } else {
@@ -198,23 +209,33 @@ export default class Extensions extends BaseClass {
198209 }
199210
200211 log . debug ( `Extensions scope fix completed, writing updated schema` , this . config . auditContext ) ;
201- await this . writeFixContent ( newExtensionSchema ) ;
212+ await this . writeFixContent ( newExtensionSchema , userConfirm ) ;
202213 }
203214
204- async writeFixContent ( fixedExtensions : Record < string , Extension > ) {
215+ async writeFixContent ( fixedExtensions : Record < string , Extension > , preConfirmed ?: boolean ) {
205216 log . debug ( `Writing fix content for ${ Object . keys ( fixedExtensions ) . length } extensions` , this . config . auditContext ) ;
206217 log . debug ( `Fix mode: ${ this . fix } ` , this . config . auditContext ) ;
207218 log . debug ( `Copy directory flag: ${ this . config . flags [ 'copy-dir' ] } ` , this . config . auditContext ) ;
208219 log . debug ( `External config skip confirm: ${ this . config . flags [ 'external-config' ] ?. skipConfirm } ` , this . config . auditContext ) ;
209220 log . debug ( `Yes flag: ${ this . config . flags . yes } ` , this . config . auditContext ) ;
210221
211- if (
212- this . fix &&
213- ( this . config . flags [ 'copy-dir' ] ||
214- this . config . flags [ 'external-config' ] ?. skipConfirm ||
215- this . config . flags . yes ||
216- ( await cliux . confirm ( commonMsg . FIX_CONFIRMATION ) ) )
222+ let shouldWrite : boolean ;
223+ if ( ! this . fix ) {
224+ shouldWrite = false ;
225+ } else if ( preConfirmed !== undefined ) {
226+ shouldWrite = preConfirmed ;
227+ } else if (
228+ this . config . flags [ 'copy-dir' ] ||
229+ this . config . flags [ 'external-config' ] ?. skipConfirm ||
230+ this . config . flags . yes
217231 ) {
232+ shouldWrite = true ;
233+ } else {
234+ this . completeProgress ( true ) ;
235+ shouldWrite = await cliux . confirm ( commonMsg . FIX_CONFIRMATION ) ;
236+ }
237+
238+ if ( shouldWrite ) {
218239 const outputPath = join ( this . folderPath , this . config . moduleConfig [ this . moduleName ] . fileName ) ;
219240 log . debug ( `Writing fixed extensions to: ${ outputPath } ` , this . config . auditContext ) ;
220241 log . debug ( `Extensions to write: ${ Object . keys ( fixedExtensions ) . join ( ', ' ) } ` , this . config . auditContext ) ;
0 commit comments