@@ -964,6 +964,7 @@ Note: Certain tabs will only be shown if applicable to a given dependency`,
964964 }
965965
966966 let sourceFolder ;
967+ let sourceFileInput : string | undefined ;
967968 if ( program . args . length > 0 ) {
968969 /**
969970 * tsconfig file provided with source folder in arg
@@ -978,14 +979,22 @@ Note: Certain tabs will only be shown if applicable to a given dependency`,
978979 ) ;
979980 }
980981
981- sourceFolder = program . args [ 0 ] ;
982- if ( ! FileEngine . existsSync ( sourceFolder ) ) {
982+ const providedSourcePath = program . args [ 0 ] ;
983+ if ( ! FileEngine . existsSync ( providedSourcePath ) ) {
983984 logger . error (
984- `Provided source folder ${ sourceFolder } was not found in the current directory` ,
985+ `Provided source ${ providedSourcePath } was not found in the current directory` ,
985986 ) ;
986987 process . exit ( 1 ) ;
987988 } else {
988- logger . info ( "Using provided source folder" ) ;
989+ const sourceStats = fs . statSync ( providedSourcePath ) ;
990+ if ( sourceStats . isFile ( ) ) {
991+ sourceFolder = path . dirname ( providedSourcePath ) ;
992+ sourceFileInput = providedSourcePath ;
993+ logger . info ( "Using provided source file" ) ;
994+ } else {
995+ sourceFolder = providedSourcePath ;
996+ logger . info ( "Using provided source folder" ) ;
997+ }
989998 }
990999 }
9911000
@@ -1029,6 +1038,12 @@ Note: Certain tabs will only be shown if applicable to a given dependency`,
10291038 includeFiles = [ ...includeFiles , ...scannedFiles ] ;
10301039 }
10311040
1041+ if ( sourceFileInput ) {
1042+ // Restrict scanning to the provided single file to avoid treating it as a directory.
1043+ includeFiles = [ path . basename ( sourceFileInput ) ] ;
1044+ scannedFiles = [ ] ;
1045+ }
1046+
10321047 if ( ! includeFiles . length ) {
10331048 includeFiles = INCLUDE_PATTERNS ;
10341049 }
0 commit comments