@@ -18,6 +18,7 @@ import { printFixTips } from '../ui/compare/printFixTips.js';
1818import { printStats } from '../ui/compare/printStats.js' ;
1919import { printDuplicates } from '../ui/compare/printDuplicates.js' ;
2020import { printHeader } from '../ui/compare/printHeader.js' ;
21+ import { printAutoFix } from '../ui/compare/printAutoFix.js' ;
2122
2223/**
2324 * Compares multiple pairs of .env and .env.example files.
@@ -258,43 +259,15 @@ export async function compareMany(
258259 }
259260
260261 if ( opts . fix ) {
261- const { changed, result } = applyFixes ( {
262- envPath,
263- examplePath,
264- missingKeys : filtered . missing ,
265- duplicateKeys : dupsEnv . map ( ( d ) => d . key ) ,
266- } ) ;
262+ const { changed, result } = applyFixes ( {
263+ envPath,
264+ examplePath,
265+ missingKeys : filtered . missing ,
266+ duplicateKeys : dupsEnv . map ( ( d ) => d . key ) ,
267+ } ) ;
267268
268- if ( ! opts . json ) {
269- if ( changed ) {
270- console . log ( chalk . green ( '✅ Auto-fix applied:' ) ) ;
271- if ( result . removedDuplicates . length ) {
272- console . log (
273- chalk . green (
274- ` - Removed ${ result . removedDuplicates . length } duplicate keys from ${ envName } : ${ result . removedDuplicates . join ( ', ' ) } ` ,
275- ) ,
276- ) ;
277- }
278- if ( result . addedEnv . length ) {
279- console . log (
280- chalk . green (
281- ` - Added ${ result . addedEnv . length } missing keys to ${ envName } : ${ result . addedEnv . join ( ', ' ) } ` ,
282- ) ,
283- ) ;
284- }
285- if ( result . addedExample . length ) {
286- console . log (
287- chalk . green (
288- ` - Synced ${ result . addedExample . length } keys to ${ exampleName } : ${ result . addedExample . join ( ', ' ) } ` ,
289- ) ,
290- ) ;
291- }
292- } else {
293- console . log ( chalk . green ( '✅ Auto-fix applied: no changes needed.' ) ) ;
294- }
295- console . log ( ) ;
296- }
297- }
269+ printAutoFix ( changed , result , envName , exampleName , opts . json ) ;
270+ }
298271
299272 opts . collect ?.( entry ) ;
300273 const warningsExist =
0 commit comments