@@ -27,23 +27,44 @@ answers.find[path.normalize('/srcDir')] = [
2727 path . normalize ( '/srcDir/someOtherDir3' ) ,
2828] ;
2929runner . setAnswers ( answers ) ;
30- runner . registerMockExport ( 'stats' , ( itemPath : string ) => {
31- console . log ( '##vso[task.debug]stats ' + itemPath ) ;
30+
31+ fs . existsSync = ( itemPath : string ) => {
32+ switch ( itemPath ) {
33+ case path . normalize ( '/srcDir' ) :
34+ case path . normalize ( '/srcDir/someOtherDir' ) :
35+ case path . normalize ( '/srcDir/someOtherDir/file1.file' ) :
36+ case path . normalize ( '/srcDir/someOtherDir/file2.file' ) :
37+ case path . normalize ( '/srcDir/someOtherDir2' ) :
38+ case path . normalize ( '/srcDir/someOtherDir2/file1.file' ) :
39+ case path . normalize ( '/srcDir/someOtherDir2/file2.file' ) :
40+ case path . normalize ( '/srcDir/someOtherDir2/file3.file' ) :
41+ case path . normalize ( '/srcDir/someOtherDir3' ) :
42+ return true ;
43+ default :
44+ return false ;
45+ }
46+ }
47+
48+ fs . statSync = ( itemPath : string ) => {
49+ const itemStats : fs . Stats = new fs . Stats ( ) ;
3250 switch ( itemPath ) {
3351 case path . normalize ( '/srcDir/someOtherDir' ) :
3452 case path . normalize ( '/srcDir/someOtherDir2' ) :
3553 case path . normalize ( '/srcDir/someOtherDir3' ) :
36- return { isDirectory : ( ) => true } ;
54+ itemStats . isDirectory = ( ) => true ;
55+ break ;
3756 case path . normalize ( '/srcDir/someOtherDir/file1.file' ) :
3857 case path . normalize ( '/srcDir/someOtherDir/file2.file' ) :
3958 case path . normalize ( '/srcDir/someOtherDir2/file1.file' ) :
4059 case path . normalize ( '/srcDir/someOtherDir2/file2.file' ) :
4160 case path . normalize ( '/srcDir/someOtherDir2/file3.file' ) :
42- return { isDirectory : ( ) => false } ;
61+ itemStats . isDirectory = ( ) => false ;
62+ break ;
4363 default :
4464 throw { code : 'ENOENT' } ;
4565 }
46- } ) ;
66+ return itemStats ;
67+ }
4768
4869// as a precaution, disable fs.chmodSync. it should not be called during this scenario.
4970fs . chmodSync = null ;
0 commit comments