@@ -36,10 +36,13 @@ export function outputToConsole(
3636) : { exitWithError : boolean } {
3737 let exitWithError = false ;
3838
39+ // Determine if output should be in JSON format
40+ const isJson = opts . json ?? false ;
41+
3942 printHeader ( comparedAgainst ) ;
4043
4144 // Show stats if requested
42- printStats ( scanResult . stats , opts . json ?? false , opts . showStats ?? true ) ;
45+ printStats ( scanResult . stats , isJson , opts . showStats ?? true ) ;
4346
4447 // Show used variables if any found
4548 if ( scanResult . stats . uniqueVariables > 0 ) {
@@ -49,7 +52,7 @@ export function outputToConsole(
4952 printVariables (
5053 scanResult . used ,
5154 opts . showStats ?? false ,
52- opts . json ?? false ,
55+ isJson ,
5356 ) ;
5457 }
5558
@@ -60,7 +63,7 @@ export function outputToConsole(
6063 scanResult . used ,
6164 comparedAgainst ,
6265 opts . isCiMode ?? false ,
63- opts . json ?? false ,
66+ isJson ,
6467 )
6568 ) {
6669 exitWithError = true ;
@@ -71,7 +74,7 @@ export function outputToConsole(
7174 scanResult . unused ,
7275 comparedAgainst ,
7376 opts . showUnused ?? false ,
74- opts . json ?? false ,
77+ isJson ,
7578 ) ;
7679
7780 // Duplicates
@@ -80,11 +83,11 @@ export function outputToConsole(
8083 'example file' ,
8184 scanResult . duplicates ?. env ?? [ ] ,
8285 scanResult . duplicates ?. example ?? [ ] ,
83- opts . json ?? false ,
86+ isJson ,
8487 ) ;
8588
8689 // Print potential secrets found
87- printSecrets ( scanResult . secrets ?? [ ] , opts . json ?? false ) ;
90+ printSecrets ( scanResult . secrets ?? [ ] , isJson ) ;
8891
8992 // Success message for env file comparison
9093 if (
@@ -94,7 +97,7 @@ export function outputToConsole(
9497 scanResult . used . length > 0
9598 ) {
9699 printSuccess (
97- opts . json ?? false ,
100+ isJson ,
98101 'scan' ,
99102 comparedAgainst ,
100103 scanResult . unused ,
@@ -126,7 +129,7 @@ export function outputToConsole(
126129 secrets : scanResult . secrets ?. length ?? 0 ,
127130 hasGitignoreIssue,
128131 } ,
129- opts . json ?? false ,
132+ isJson ,
130133 ) ;
131134
132135 if ( exit ) exitWithError = true ;
@@ -142,7 +145,7 @@ export function outputToConsole(
142145 } ,
143146 comparedAgainst || '.env' ,
144147 opts . examplePath ? path . basename ( opts . examplePath ) : 'example file' ,
145- opts . json ?? false ,
148+ isJson ,
146149 fixContext . gitignoreUpdated ,
147150 ) ;
148151 }
@@ -158,7 +161,7 @@ export function outputToConsole(
158161 printFixTips (
159162 filtered ,
160163 hasGitignoreIssue ,
161- opts . json ?? false ,
164+ isJson ,
162165 opts . fix ?? false ,
163166 ) ;
164167
0 commit comments