@@ -3,14 +3,26 @@ import path from 'path';
33import { type ScanUsageOptions } from '../config/types.js' ;
44import { resolveFromCwd } from './helpers/resolveFromCwd.js' ;
55
6+ type ComparisonFile = {
7+ path : string ;
8+ name : string ;
9+ } ;
10+
11+ const DEFAULT_ENV_FILES = [
12+ '.env' ,
13+ '.env.example' ,
14+ '.env.local' ,
15+ '.env.production' ,
16+ ] as const ;
17+
618/**
719 * Determines which file to use for comparison based on provided options
820 * @param {ScanUsageOptions } opts - Scan configuration options
9- * @returns { Object|null } - The comparison file information or undefined if not found
21+ * @returns Comparison file info with absolute path and basename, or undefined if not found
1022 */
1123export function determineComparisonFile (
1224 opts : ScanUsageOptions ,
13- ) : { path : string ; name : string } | undefined {
25+ ) : ComparisonFile | undefined {
1426 // Priority: explicit flags first, then auto-discovery
1527
1628 if ( opts . examplePath ) {
@@ -28,8 +40,7 @@ export function determineComparisonFile(
2840 }
2941
3042 // Auto-discovery: look for common env files relative to cwd
31- const candidates = [ '.env' , '.env.example' , '.env.local' , '.env.production' ] ;
32- for ( const candidate of candidates ) {
43+ for ( const candidate of DEFAULT_ENV_FILES ) {
3344 const fullPath = path . resolve ( opts . cwd , candidate ) ;
3445 if ( fs . existsSync ( fullPath ) ) {
3546 return { path : fullPath , name : candidate } ;
0 commit comments