@@ -438,21 +438,11 @@ export function findSarifFilesInDir(
438438export function getSarifFilePaths (
439439 sarifPath : string ,
440440 isSarif : ( name : string ) => boolean ,
441+ pathStats : fs . Stats ,
441442) {
442- if ( ! fs . existsSync ( sarifPath ) ) {
443- // This is always a configuration error, even for first-party runs.
444- throw new ConfigurationError ( `Path does not exist: ${ sarifPath } ` ) ;
445- }
446-
447443 let sarifFiles : string [ ] ;
448- if ( fs . lstatSync ( sarifPath ) . isDirectory ( ) ) {
444+ if ( pathStats . isDirectory ( ) ) {
449445 sarifFiles = findSarifFilesInDir ( sarifPath , isSarif ) ;
450- if ( sarifFiles . length === 0 ) {
451- // This is always a configuration error, even for first-party runs.
452- throw new ConfigurationError (
453- `No SARIF files found to upload in "${ sarifPath } ".` ,
454- ) ;
455- }
456446 } else {
457447 sarifFiles = [ sarifPath ] ;
458448 }
@@ -623,11 +613,26 @@ export async function uploadFiles(
623613 logger : Logger ,
624614 uploadTarget : analyses . AnalysisConfig ,
625615) : Promise < UploadResult > {
616+ const pathStats = fs . lstatSync ( inputSarifPath , { throwIfNoEntry : false } ) ;
617+
618+ if ( pathStats === undefined ) {
619+ // This is always a configuration error, even for first-party runs.
620+ throw new ConfigurationError ( `Path does not exist: ${ inputSarifPath } ` ) ;
621+ }
622+
626623 const sarifPaths = getSarifFilePaths (
627624 inputSarifPath ,
628625 uploadTarget . sarifPredicate ,
626+ pathStats ,
629627 ) ;
630628
629+ if ( sarifPaths . length === 0 ) {
630+ // This is always a configuration error, even for first-party runs.
631+ throw new ConfigurationError (
632+ `No SARIF files found to upload in "${ inputSarifPath } ".` ,
633+ ) ;
634+ }
635+
631636 return uploadSpecifiedFiles (
632637 sarifPaths ,
633638 checkoutPath ,
0 commit comments