@@ -59,6 +59,12 @@ interface IOLog {
5959 path : string ;
6060 result ?: string ;
6161 } [ ] ;
62+ directoriesRead : {
63+ path : string ,
64+ extension : string ,
65+ exclude : string [ ] ,
66+ result : string [ ]
67+ } [ ] ;
6268}
6369
6470interface PlaybackControl {
@@ -103,6 +109,7 @@ module Playback {
103109 arguments : [ ] ,
104110 currentDirectory : "" ,
105111 filesRead : [ ] ,
112+ directoriesRead : [ ] ,
106113 filesWritten : [ ] ,
107114 filesDeleted : [ ] ,
108115 filesAppended : [ ] ,
@@ -118,7 +125,7 @@ module Playback {
118125
119126 function initWrapper ( wrapper : PlaybackSystem , underlying : ts . System ) : void ;
120127 function initWrapper ( wrapper : PlaybackIO , underlying : Harness . IO ) : void ;
121- function initWrapper ( wrapper : PlaybackSystem | PlaybackIO , underlying : ts . System | Harness . IO ) : void {
128+ function initWrapper ( wrapper : PlaybackSystem | PlaybackIO , underlying : ts . System | Harness . IO ) : void {
122129 ts . forEach ( Object . keys ( underlying ) , prop => {
123130 ( < any > wrapper ) [ prop ] = ( < any > underlying ) [ prop ] ;
124131 } ) ;
@@ -203,6 +210,15 @@ module Playback {
203210 } ,
204211 memoize ( ( path ) => findResultByPath ( wrapper , replayLog . filesRead , path ) . contents ) ) ;
205212
213+ wrapper . readDirectory = recordReplay ( wrapper . readDirectory , underlying ) (
214+ ( path , extension , exclude ) => {
215+ let result = ( < ts . System > underlying ) . readDirectory ( path , extension , exclude ) ;
216+ let logEntry = { path, extension, exclude, result } ;
217+ recordLog . directoriesRead . push ( logEntry ) ;
218+ return result ;
219+ } ,
220+ ( path , extension , exclude ) => findResultByPath ( wrapper , replayLog . directoriesRead . filter ( d => d . extension === extension && ts . arrayIsEqualTo ( d . exclude , exclude ) ) , path ) ) ;
221+
206222 wrapper . writeFile = recordReplay ( wrapper . writeFile , underlying ) (
207223 ( path , contents ) => callAndRecord ( underlying . writeFile ( path , contents ) , recordLog . filesWritten , { path : path , contents : contents , bom : false } ) ,
208224 ( path , contents ) => noOpReplay ( "writeFile" ) ) ;
0 commit comments