@@ -6,11 +6,18 @@ import { diffEnv } from '../core/diffEnv.js';
66import { warnIfEnvNotIgnored , isEnvIgnoredByGit } from '../services/git.js' ;
77import { findDuplicateKeys } from '../services/duplicates.js' ;
88import { filterIgnoredKeys } from '../core/filterIgnoredKeys.js' ;
9- import type { Category , CompareJsonEntry , ComparisonOptions , FilePair , ComparisonResult } from '../config/types.js' ;
9+ import type {
10+ Category ,
11+ CompareJsonEntry ,
12+ ComparisonOptions ,
13+ FilePair ,
14+ ComparisonResult ,
15+ } from '../config/types.js' ;
1016import { applyFixes } from '../core/fixEnv.js' ;
1117import { printFixTips } from '../ui/compare/printFixTips.js' ;
1218import { printStats } from '../ui/compare/printStats.js' ;
1319import { printDuplicates } from '../ui/compare/printDuplicates.js' ;
20+ import { printHeader } from '../ui/compare/printHeader.js' ;
1421
1522/**
1623 * Compares multiple pairs of .env and .env.example files.
@@ -42,24 +49,16 @@ export async function compareMany(
4249 const exampleName = path . basename ( examplePath ) ;
4350 const entry : CompareJsonEntry = { env : envName , example : exampleName } ;
4451
45- if ( ! fs . existsSync ( envPath ) || ! fs . existsSync ( examplePath ) ) {
46- if ( ! opts . json ) {
47- console . log ( ) ;
48- console . log ( chalk . blue ( `🔍 Comparing ${ envName } ↔ ${ exampleName } ...` ) ) ;
49- console . log (
50- chalk . yellow ( '⚠️ Skipping: missing matching example file.' ) ,
51- ) ;
52- console . log ( ) ;
53- }
52+ const skipping = ! fs . existsSync ( envPath ) || ! fs . existsSync ( examplePath ) ;
53+
54+ if ( skipping ) {
55+ printHeader ( envName , exampleName , opts . json , skipping ) ;
56+ exitWithError = true ;
5457 entry . skipped = { reason : 'missing file' } ;
5558 opts . collect ?.( entry ) ;
5659 continue ;
57- }
58-
59- if ( ! opts . json ) {
60- console . log ( ) ;
61- console . log ( chalk . blue ( `🔍 Comparing ${ envName } ↔ ${ exampleName } ...` ) ) ;
62- console . log ( ) ;
60+ } else {
61+ printHeader ( envName , exampleName , opts . json , skipping ) ;
6362 }
6463
6564 // Git ignore hint (only when not JSON)
@@ -150,13 +149,20 @@ export async function compareMany(
150149 ? filtered . mismatches . length
151150 : 0 ;
152151
153- printStats ( envName , exampleName , {
152+ printStats (
153+ envName ,
154+ exampleName ,
155+ {
154156 envCount,
155157 exampleCount,
156158 sharedCount,
157159 duplicateCount,
158160 valueMismatchCount,
159- } , filtered , opts . json ?? false , opts . showStats ) ;
161+ } ,
162+ filtered ,
163+ opts . json ?? false ,
164+ opts . showStats ,
165+ ) ;
160166 }
161167
162168 const allOk =
@@ -177,13 +183,7 @@ export async function compareMany(
177183 continue ;
178184 }
179185
180- printDuplicates (
181- envName ,
182- exampleName ,
183- dupsEnv ,
184- dupsEx ,
185- opts . json ?? false ,
186- ) ;
186+ printDuplicates ( envName , exampleName , dupsEnv , dupsEx , opts . json ?? false ) ;
187187
188188 if ( filtered . missing . length ) {
189189 entry . missing = filtered . missing ;
0 commit comments